Patch #931938: prevent setting sys.prefix to ""
authorGeorg Brandl <georg@python.org>
Mon, 20 Feb 2006 17:37:36 +0000 (17:37 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 20 Feb 2006 17:37:36 +0000 (17:37 +0000)
Modules/getpath.c

index 3264e246a41af6bed459fb52d3a6c61834657df1..4716d154587e6dac1cb3d3ac40ddcb44de7498ce 100644 (file)
@@ -628,6 +628,10 @@ calculate_path(void)
     if (pfound > 0) {
         reduce(prefix);
         reduce(prefix);
+       /* The prefix is the root directory, but reduce() chopped
+        * off the "/". */
+       if (!prefix[0])
+               strcpy(prefix, separator);
     }
     else
         strncpy(prefix, PREFIX, MAXPATHLEN);
@@ -636,6 +640,8 @@ calculate_path(void)
         reduce(exec_prefix);
         reduce(exec_prefix);
         reduce(exec_prefix);
+       if (!exec_prefix[0])
+               strcpy(exec_prefix, separator);
     }
     else
         strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN);