]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
copy_absolute() keeps the relative path on _Py_wgetcwd() failure
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 7 Oct 2010 23:29:18 +0000 (23:29 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 7 Oct 2010 23:29:18 +0000 (23:29 +0000)
.. instead of raising a fatal error. Even if the current directory was deleted,
use relative paths may still work (eg. run Python with "../python").

Modules/getpath.c

index ee784dd7f1c1f0064e6774f0a53f1dd446580d7b..9e5934d739edab45c9d4ef4aca192cb886b0388a 100644 (file)
@@ -236,8 +236,11 @@ copy_absolute(wchar_t *path, wchar_t *p)
     if (p[0] == SEP)
         wcscpy(path, p);
     else {
-        if (!_Py_wgetcwd(path, MAXPATHLEN))
-            Py_FatalError("unable to get the current directory");
+        if (!_Py_wgetcwd(path, MAXPATHLEN)) {
+            /* unable to get the current directory */
+            wcscpy(path, p);
+            return;
+        }
         if (p[0] == '.' && p[1] == SEP)
             p += 2;
         joinpath(path, p);