GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing bugs.python.org — bugs.python.org diff -up Python-2.6/Python/sysmodule.c.dont-add-cwd-for-embedded-interpreter Python-2.6/Python/sysmodule.c
--- Python-2.6/Python/sysmodule.c.dont-add-cwd-for-embedded-interpreter 2009-03-11 21:57:46.518786909 -0400
+++ Python-2.6/Python/sysmodule.c 2009-03-11 22:10:05.001786556 -0400
@@ -1521,6 +1521,18 @@ makeargvobject(int argc, char **argv)
return av;
}
+static int
+is_embedded (void)
+{
+ /* Programs that embed python for plugins tend
+ * to not call Py_SetProgramName() so they still
+ * have the default of "python"
+ *
+ * (whereas python itself uses "/usr/bin/python")
+ */
+ return strcmp(Py_GetProgramName(), "python") == 0;
+}
+
void
PySys_SetArgv(int argc, char **argv)
{
@@ -1540,7 +1552,7 @@ PySys_SetArgv(int argc, char **argv)
if (path != NULL) {
char *argv0 = argv[0];
char *p = NULL;
- Py_ssize_t n = 0;
+ Py_ssize_t n = -1;
PyObject *a;
#ifdef HAVE_CANONICALIZE_FILE_NAME
char *link = NULL, *argv0copy = NULL;
@@ -1673,16 +1685,23 @@ PySys_SetArgv(int argc, char **argv)
}
#endif /* All others */
#endif /* ! HAVE_CANONICALIZE_FILE_NAME */
- a = PyString_FromStringAndSize(argv0, n);
- if (a == NULL)
- Py_FatalError("no mem for sys.path insertion");
+ if (n != -1 && !is_embedded()) {
+ a = PyString_FromStringAndSize(argv0, n);
+ if (a == NULL)
+ Py_FatalError("no mem for sys.path insertion");
#ifdef HAVE_CANONICALIZE_FILE_NAME
- if (argc > 0 && argv0 != NULL)
- free(argv0);
+ if (argc > 0 && argv0 != NULL)
+ free(argv0);
#endif /* HAVE_CANONICALIZE_FILE_NAME */
- if (PyList_Insert(path, 0, a) < 0)
- Py_FatalError("sys.path.insert(0) failed");
- Py_DECREF(a);
+ if (PyList_Insert(path, 0, a) < 0)
+ Py_FatalError("sys.path.insert(0) failed");
+ Py_DECREF(a);
+ } else {
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ if (argc > 0 && argv0 != NULL)
+ free(argv0);
+#endif /* HAVE_CANONICALIZE_FILE_NAME */
+ }
}
Py_DECREF(av);
}
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |