Issue #9850: Fixed macpath.join() for empty first component. Patch by

Oleg Oshmyan.
This commit is contained in:
Serhiy Storchaka 2014-09-27 18:55:15 +03:00
commit 402e1e388d
3 changed files with 28 additions and 1 deletions

View File

@ -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:

View File

@ -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

View File

@ -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.