summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-19 15:09:27 (GMT)
committerGitHub <noreply@github.com>2019-03-19 15:09:27 (GMT)
commitdcf617152e1d4c4a5e7965733928858a9c0936ca (patch)
tree61c2ce7f9a4bcb8a1f48efb1a24b0f50d4029372 /Modules
parentf5f336a819a3d881bb217bf8f9b5cacba03a4e45 (diff)
downloadcpython-dcf617152e1d4c4a5e7965733928858a9c0936ca.zip
cpython-dcf617152e1d4c4a5e7965733928858a9c0936ca.tar.gz
cpython-dcf617152e1d4c4a5e7965733928858a9c0936ca.tar.bz2
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].
Diffstat (limited to 'Modules')
-rw-r--r--Modules/main.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 99396b7..df4eca5 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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};