summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-27 15:55:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-27 15:55:15 (GMT)
commit402e1e388d0e686b761768e672832b6ab9ca1dec (patch)
treee095063eded91105da0097e82de8903a0369d902
parentfe21e4d4d76d3fd1efd16d124808d72a69588d7b (diff)
parentca534ab4957f3ed081133f2174543d8a560a4051 (diff)
downloadcpython-402e1e388d0e686b761768e672832b6ab9ca1dec.zip
cpython-402e1e388d0e686b761768e672832b6ab9ca1dec.tar.gz
cpython-402e1e388d0e686b761768e672832b6ab9ca1dec.tar.bz2
Issue #9850: Fixed macpath.join() for empty first component. Patch by
Oleg Oshmyan.
-rw-r--r--Lib/macpath.py2
-rw-r--r--Lib/test/test_macpath.py24
-rw-r--r--Misc/NEWS3
3 files changed, 28 insertions, 1 deletions
diff --git a/Lib/macpath.py b/Lib/macpath.py
index d34f9e94..5ca0097 100644
--- a/Lib/macpath.py
+++ b/Lib/macpath.py
@@ -53,7 +53,7 @@ def join(s, *p):
colon = _get_colon(s)
path = s
for t in p:
- if (not s) or isabs(t):
+ if (not path) or isabs(t):
path = t
continue
if t[:1] == colon:
diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py
index ae4e564..22f8491 100644
--- a/Lib/test/test_macpath.py
+++ b/Lib/test/test_macpath.py
@@ -49,16 +49,40 @@ class MacPathTestCase(unittest.TestCase):
def test_join(self):
join = macpath.join
self.assertEqual(join('a', 'b'), ':a:b')
+ self.assertEqual(join(':a', 'b'), ':a:b')
+ self.assertEqual(join(':a:', 'b'), ':a:b')
+ self.assertEqual(join(':a::', 'b'), ':a::b')
+ self.assertEqual(join(':a', '::b'), ':a::b')
+ self.assertEqual(join('a', ':'), ':a:')
+ self.assertEqual(join('a:', ':'), 'a:')
+ self.assertEqual(join('a', ''), ':a:')
+ self.assertEqual(join('a:', ''), 'a:')
+ self.assertEqual(join('', ''), '')
self.assertEqual(join('', 'a:b'), 'a:b')
+ self.assertEqual(join('', 'a', 'b'), ':a:b')
self.assertEqual(join('a:b', 'c'), 'a:b:c')
self.assertEqual(join('a:b', ':c'), 'a:b:c')
self.assertEqual(join('a', ':b', ':c'), ':a:b:c')
+ self.assertEqual(join('a', 'b:'), 'b:')
+ self.assertEqual(join('a:', 'b:'), 'b:')
self.assertEqual(join(b'a', b'b'), b':a:b')
+ self.assertEqual(join(b':a', b'b'), b':a:b')
+ self.assertEqual(join(b':a:', b'b'), b':a:b')
+ self.assertEqual(join(b':a::', b'b'), b':a::b')
+ self.assertEqual(join(b':a', b'::b'), b':a::b')
+ self.assertEqual(join(b'a', b':'), b':a:')
+ self.assertEqual(join(b'a:', b':'), b'a:')
+ self.assertEqual(join(b'a', b''), b':a:')
+ self.assertEqual(join(b'a:', b''), b'a:')
+ self.assertEqual(join(b'', b''), b'')
self.assertEqual(join(b'', b'a:b'), b'a:b')
+ self.assertEqual(join(b'', b'a', b'b'), b':a:b')
self.assertEqual(join(b'a:b', b'c'), b'a:b:c')
self.assertEqual(join(b'a:b', b':c'), b'a:b:c')
self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c')
+ self.assertEqual(join(b'a', b'b:'), b'b:')
+ self.assertEqual(join(b'a:', b'b:'), b'b:')
def test_splitext(self):
splitext = macpath.splitext
diff --git a/Misc/NEWS b/Misc/NEWS
index e96b659..4fd4f17 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -145,6 +145,9 @@ Core and Builtins
Library
-------
+- Issue #9850: Fixed macpath.join() for empty first component. Patch by
+ Oleg Oshmyan.
+
- Issue #5309: distutils' build and build_ext commands now accept a ``-j``
option to enable parallel building of extension modules.