mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Call Py_SetProgramName() instead of redefining getprogramname(),
reflecting changes in the runtime around 1.5 or earlier.
This commit is contained in:
parent
eb894ebd0a
commit
496bc7f238
1 changed files with 3 additions and 11 deletions
|
|
@ -2,16 +2,14 @@
|
|||
|
||||
#include "Python.h"
|
||||
|
||||
static char *argv0;
|
||||
|
||||
void initxyzzy(); /* Forward */
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
/* Save a copy of argv0 */
|
||||
argv0 = argv[0];
|
||||
/* Pass argv[0] to the Python interpreter */
|
||||
Py_SetProgramName(argv[0]);
|
||||
|
||||
/* Initialize the Python interpreter. Required. */
|
||||
Py_Initialize();
|
||||
|
|
@ -32,6 +30,7 @@ main(argc, argv)
|
|||
PyRun_SimpleString("import sys\n");
|
||||
PyRun_SimpleString("print sys.builtin_module_names\n");
|
||||
PyRun_SimpleString("print sys.modules.keys()\n");
|
||||
PyRun_SimpleString("print sys.executable\n");
|
||||
PyRun_SimpleString("print sys.argv\n");
|
||||
|
||||
/* Note that you can call any public function of the Python
|
||||
|
|
@ -45,13 +44,6 @@ main(argc, argv)
|
|||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/* This function is called by the interpreter to get its own name */
|
||||
char *
|
||||
getprogramname()
|
||||
{
|
||||
return argv0;
|
||||
}
|
||||
|
||||
/* A static module */
|
||||
|
||||
static PyObject *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue