File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,10 +20,19 @@ main(int argc, char **argv)
2020 Py_Initialize ();
2121
2222 /* Define sys.argv. It is up to the application if you
23- want this; you can also let it undefined (since the Python
23+ want this; you can also leave it undefined (since the Python
2424 code is generally not a main program it has no business
25- touching sys.argv...) */
26- PySys_SetArgv (2 , args );
25+ touching sys.argv...)
26+
27+ If the third argument is true, sys.path is modified to include
28+ either the directory containing the script named by argv[0], or
29+ the current working directory. This can be risky; if you run
30+ an application embedding Python in a directory controlled by
31+ someone else, attackers could put a Trojan-horse module in the
32+ directory (say, a file named os.py) that your application would
33+ then import and run.
34+ */
35+ PySys_SetArgvEx (argc , argv , 0 );
2736
2837 /* Do some application specific code */
2938 printf ("Hello, brave new world\n\n" );
Original file line number Diff line number Diff line change @@ -519,12 +519,12 @@ the table of loaded modules, and creates the fundamental modules
519519:mod: `builtins `, :mod: `__main__ `, :mod: `sys `, and :mod: `exceptions `. It also
520520initializes the module search path (``sys.path ``).
521521
522- .. index :: single: PySys_SetArgv ()
522+ .. index :: single: PySys_SetArgvEx ()
523523
524524:cfunc: `Py_Initialize ` does not set the "script argument list" (``sys.argv ``).
525- If this variable is needed by Python code that will be executed later, it must
526- be set explicitly with a call to ``PySys_SetArgv (argc, argv) `` subsequent to
527- the call to :cfunc: `Py_Initialize `.
525+ If this variable is needed by Python code that will be executed later, it must
526+ be set explicitly with a call to ``PySys_SetArgvEx (argc, argv, updatepath ) ``
527+ after the call to :cfunc: `Py_Initialize `.
528528
529529On most systems (in particular, on Unix and Windows, although the details are
530530slightly different), :cfunc: `Py_Initialize ` calculates the module search path
You can’t perform that action at this time.
0 commit comments