Kaydet (Commit) 496bc7f2 authored tarafından Guido van Rossum's avatar Guido van Rossum

Call Py_SetProgramName() instead of redefining getprogramname(),

reflecting changes in the runtime around 1.5 or earlier.
üst eb894ebd
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
#include "Python.h" #include "Python.h"
static char *argv0;
void initxyzzy(); /* Forward */ void initxyzzy(); /* Forward */
main(argc, argv) main(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
/* Save a copy of argv0 */ /* Pass argv[0] to the Python interpreter */
argv0 = argv[0]; Py_SetProgramName(argv[0]);
/* Initialize the Python interpreter. Required. */ /* Initialize the Python interpreter. Required. */
Py_Initialize(); Py_Initialize();
...@@ -32,6 +30,7 @@ main(argc, argv) ...@@ -32,6 +30,7 @@ main(argc, argv)
PyRun_SimpleString("import sys\n"); PyRun_SimpleString("import sys\n");
PyRun_SimpleString("print sys.builtin_module_names\n"); PyRun_SimpleString("print sys.builtin_module_names\n");
PyRun_SimpleString("print sys.modules.keys()\n"); PyRun_SimpleString("print sys.modules.keys()\n");
PyRun_SimpleString("print sys.executable\n");
PyRun_SimpleString("print sys.argv\n"); PyRun_SimpleString("print sys.argv\n");
/* Note that you can call any public function of the Python /* Note that you can call any public function of the Python
...@@ -45,13 +44,6 @@ main(argc, argv) ...@@ -45,13 +44,6 @@ main(argc, argv)
/*NOTREACHED*/ /*NOTREACHED*/
} }
/* This function is called by the interpreter to get its own name */
char *
getprogramname()
{
return argv0;
}
/* A static module */ /* A static module */
static PyObject * static PyObject *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment