[Python-checkins] cpython (merge 3.5 -> 3.6): Issue #19398: Extra slash no longer added to sys.path components in case of
serhiy.storchaka
python-checkins at python.org
Fri Nov 11 05:12:25 EST 2016
https://hg.python.org/cpython/rev/1a88baaed7a0
changeset: 105053:1a88baaed7a0
branch: 3.6
parent: 105050:c89f213b21e8
parent: 105052:db220f2df5a9
user: Serhiy Storchaka <storchaka at gmail.com>
date: Fri Nov 11 12:06:38 2016 +0200
summary:
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.
files:
Lib/test/test_trace.py | 8 ++++----
Misc/NEWS | 3 +++
Modules/getpath.c | 5 ++++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -311,11 +311,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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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 #28583: PyDict_SetDefault didn't combine split table when needed.
Patch by Xiang Zhang.
diff --git a/Modules/getpath.c b/Modules/getpath.c
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -762,7 +762,10 @@
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) {
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list