changeset: 105055:237ef36fb1bb branch: 2.7 parent: 105048:bc81f2137706 user: Serhiy Storchaka date: Fri Nov 11 12:11:55 2016 +0200 files: Lib/test/test_trace.py Misc/NEWS Modules/getpath.c description: Issue #19398: Extra slash no longer added to sys.path components in case of empty compile-time PYTHONPATH components. This fixes some tests in -S or -I modes. diff -r bc81f2137706 -r 237ef36fb1bb Lib/test/test_trace.py --- a/Lib/test/test_trace.py Fri Nov 11 11:42:25 2016 +0200 +++ b/Lib/test/test_trace.py Fri Nov 11 12:11:55 2016 +0200 @@ -293,11 +293,11 @@ 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 diff -r bc81f2137706 -r 237ef36fb1bb Misc/NEWS --- a/Misc/NEWS Fri Nov 11 11:42:25 2016 +0200 +++ b/Misc/NEWS Fri Nov 11 12:11:55 2016 +0200 @@ -10,6 +10,9 @@ 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 diff -r bc81f2137706 -r 237ef36fb1bb Modules/getpath.c --- a/Modules/getpath.c Fri Nov 11 11:42:25 2016 +0200 +++ b/Modules/getpath.c Fri Nov 11 12:11:55 2016 +0200 @@ -597,7 +597,10 @@ 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) {