mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-36236: Handle removed cwd at Python init (GH-12424)
At Python initialization, the current directory is no longer prepended to sys.path if it has been removed. Rename _PyPathConfig_ComputeArgv0() to _PyPathConfig_ComputeSysPath0() to avoid confusion between argv[0] and sys.path[0].
This commit is contained in:
parent
f5f336a819
commit
dcf617152e
5 changed files with 52 additions and 29 deletions
|
@ -780,18 +780,20 @@ pymain_run_python(PyInterpreterState *interp, int *exitcode)
|
|||
}
|
||||
}
|
||||
else if (!config->preconfig.isolated) {
|
||||
PyObject *path0 = _PyPathConfig_ComputeArgv0(&config->argv);
|
||||
if (path0 == NULL) {
|
||||
err = _Py_INIT_NO_MEMORY();
|
||||
goto done;
|
||||
}
|
||||
PyObject *path0 = NULL;
|
||||
if (_PyPathConfig_ComputeSysPath0(&config->argv, &path0)) {
|
||||
if (path0 == NULL) {
|
||||
err = _Py_INIT_NO_MEMORY();
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (pymain_sys_path_add_path0(interp, path0) < 0) {
|
||||
if (pymain_sys_path_add_path0(interp, path0) < 0) {
|
||||
Py_DECREF(path0);
|
||||
err = _Py_INIT_EXIT(1);
|
||||
goto done;
|
||||
}
|
||||
Py_DECREF(path0);
|
||||
err = _Py_INIT_EXIT(1);
|
||||
goto done;
|
||||
}
|
||||
Py_DECREF(path0);
|
||||
}
|
||||
|
||||
PyCompilerFlags cf = {.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue