6992897 libti_pymod, libtransfer_pymod, liberrsvc call Py_Initialize without calling PySys_SetArgv
--- a/usr/src/lib/liberrsvc/errsvc.c Mon Oct 18 09:58:01 2010 -0700
+++ b/usr/src/lib/liberrsvc/errsvc.c Tue Oct 19 15:46:02 2010 -0700
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <Python.h>
@@ -60,6 +59,7 @@
#define ERR_UNKNOWN gettext("UNKNOWN ERROR")
static PyThreadState *mainThreadState = NULL;
+static char *empty_argv[1] = { "" };
int es_errno = 0;
@@ -203,6 +203,13 @@
{
if (!Py_IsInitialized()) {
Py_Initialize();
+
+ /*
+ * sys.argv needs to be initialized, just in case other
+ * modules access it. It is not initialized automatically by
+ * Py_Initialize().
+ */
+ PySys_SetArgv(1, empty_argv); /* Init sys.argv[]. */
}
if (PyErr_Occurred()) {
--- a/usr/src/lib/libti_pymod/libti.c Mon Oct 18 09:58:01 2010 -0700
+++ b/usr/src/lib/libti_pymod/libti.c Tue Oct 19 15:46:02 2010 -0700
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <Python.h>
#include <libnvpair.h>
@@ -102,6 +101,8 @@
{TI_ATTR_ZFS_VOL_NUM, DATA_TYPE_UINT16}
};
+static char *empty_argv[1] = { "" };
+
/*
* Initialize libti module.
*/
@@ -603,6 +604,13 @@
if (!Py_IsInitialized()) {
Py_Initialize();
+
+ /*
+ * sys.argv needs to be initialized, just in case other
+ * modules access it. It is not initialized automatically by
+ * Py_Initialize().
+ */
+ PySys_SetArgv(1, empty_argv); /* Init sys.argv[]. */
}
/*
@@ -651,6 +659,13 @@
if (!Py_IsInitialized()) {
Py_Initialize();
+
+ /*
+ * sys.argv needs to be initialized, just in case other
+ * modules access it. It is not initialized automatically by
+ * Py_Initialize().
+ */
+ PySys_SetArgv(1, empty_argv); /* Init sys.argv[]. */
}
/*
--- a/usr/src/lib/libtransfer_pymod/libtransfer.c Mon Oct 18 09:58:01 2010 -0700
+++ b/usr/src/lib/libtransfer_pymod/libtransfer.c Tue Oct 19 15:46:02 2010 -0700
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <Python.h>
@@ -42,7 +41,7 @@
static tm_callback_t progress;
static PyObject *py_callback = NULL;
static int dbgflag = 0;
-
+static char *empty_argv[1] = { "" };
void initlibtransfer();
@@ -154,6 +153,13 @@
Py_Initialize();
/*
+ * sys.argv needs to be initialized, just in case other
+ * modules access it. It is not initialized automatically by
+ * Py_Initialize().
+ */
+ PySys_SetArgv(1, empty_argv); /* Init sys.argv[]. */
+
+ /*
* If the Python interpreter was initialized here, allow
* destroying its context before we leave this function.
* Otherwise, keep the context alive for other potential
@@ -301,6 +307,13 @@
Py_Initialize();
/*
+ * sys.argv needs to be initialized, just in case other
+ * modules access it. It is not initialized automatically by
+ * Py_Initialize().
+ */
+ PySys_SetArgv(1, empty_argv); /* Init sys.argv[]. */
+
+ /*
* If the Python interpreter was initialized here, allow
* destroying its context before we leave this function.
* Otherwise, keep the context alive for other potential