]> 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:11:55 +0000 (12:11 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 11 Nov 2016 10:11:55 +0000 (12:11 +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 2292ad6155da8aa738a938337888e2971b89dc51..4971fcd9080a4f82aaf30e0d516ba277c25150cf 100644 (file)
@@ -293,11 +293,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 aa0044860da46b9ef3ae2a5c28a91102be03b545..d136f2b12961d4de0e9274a673546b3f4a939dce 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 2.7.13?
 Core and Builtins
 -----------------
 
+- Issue #19398: Extra slash no longer added to sys.path components in case of
+  empty compile-time PYTHONPATH components.
+
 - Issue #21720: Improve exception message when the type of fromlist is unicode.
   fromlist parameter of __import__() only accepts str in Python 2 and this
   will help to identify the problem especially when the unicode_literals
index 18b161cfee98fcdd7ab9c0f37ee7a929c224f65c..c42ce31178593fa3308cec74aa364320e0d566e9 100644 (file)
@@ -597,7 +597,10 @@ calculate_path(void)
 
             if (defpath[0] != SEP) {
                 strcat(buf, prefix);
-                strcat(buf, separator);
+                if (prefixsz >= 2 && prefix[prefixsz - 2] != SEP &&
+                    defpath[0] != (delim ? DELIM : L'\0')) {  /* not empty */
+                    strcat(buf, separator);
+                }
             }
 
             if (delim) {