]> granicus.if.org Git - python/commitdiff
Issue #19398: Extra slash no longer added to sys.path components in case of
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 11 Nov 2016 10:05:01 +0000 (12:05 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 11 Nov 2016 10:05:01 +0000 (12:05 +0200)
empty compile-time PYTHONPATH components.  This fixes some tests in -S or -I
modes.

Lib/test/test_trace.py
Misc/NEWS
Modules/getpath.c

index 03dff8432dad4e9452a08a119f8b2f1fbbe2a8b4..f66a3bc3e49dfb6e5b2f147ed8b0253e5eb31bb8 100644 (file)
@@ -311,11 +311,11 @@ class TestCoverage(unittest.TestCase):
         with captured_stdout() as stdout:
             self._coverage(tracer)
         stdout = stdout.getvalue()
-        self.assertTrue("pprint.py" in stdout)
-        self.assertTrue("case.py" in stdout)   # from unittest
+        self.assertIn("pprint.py", stdout)
+        self.assertIn("case.py", stdout)   # from unittest
         files = os.listdir(TESTFN)
-        self.assertTrue("pprint.cover" in files)
-        self.assertTrue("unittest.case.cover" in files)
+        self.assertIn("pprint.cover", files)
+        self.assertIn("unittest.case.cover", files)
 
     def test_coverage_ignore(self):
         # Ignore all files, nothing should be traced nor printed
index c408e9912a7e15325f8364a38c90787802dff559..6c9d0bcff99965d24653092988972ce6a4aab723 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Release date: TBA
 Core and Builtins
 -----------------
 
+- Issue #19398: Extra slash no longer added to sys.path components in case of
+  empty compile-time PYTHONPATH components.
+
 - Issue #28426: Fixed potential crash in PyUnicode_AsDecodedObject() in debug
   build.
 
index 18deb60dfa1d786ad99bf663c998d8e2d12762ab..c438b8e65babc48dd3a5c9cd11e298a171cf5dc1 100644 (file)
@@ -762,7 +762,10 @@ calculate_path(void)
 
         if (defpath[0] != SEP) {
             wcscat(buf, prefix);
-            wcscat(buf, separator);
+            if (prefixsz >= 2 && prefix[prefixsz - 2] != SEP &&
+                defpath[0] != (delim ? DELIM : L'\0')) {  /* not empty */
+                wcscat(buf, separator);
+            }
         }
 
         if (delim) {