Commit e430073f authored by Serhiy Storchaka's avatar Serhiy Storchaka

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

Oleg Oshmyan.
parent 6e7c1401
...@@ -42,7 +42,7 @@ def isabs(s): ...@@ -42,7 +42,7 @@ def isabs(s):
def join(s, *p): def join(s, *p):
path = s path = s
for t in p: for t in p:
if (not s) or isabs(t): if (not path) or isabs(t):
path = t path = t
continue continue
if t[:1] == ':': if t[:1] == ':':
......
...@@ -29,6 +29,26 @@ class MacPathTestCase(unittest.TestCase): ...@@ -29,6 +29,26 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(split(":conky:mountpoint:"), self.assertEqual(split(":conky:mountpoint:"),
(':conky:mountpoint', '')) (':conky:mountpoint', ''))
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:')
def test_splitext(self): def test_splitext(self):
splitext = macpath.splitext splitext = macpath.splitext
self.assertEqual(splitext(":foo.ext"), (':foo', '.ext')) self.assertEqual(splitext(":foo.ext"), (':foo', '.ext'))
......
...@@ -22,6 +22,9 @@ Core and Builtins ...@@ -22,6 +22,9 @@ Core and Builtins
Library Library
------- -------
- Issue #9850: Fixed macpath.join() for empty first component. Patch by
Oleg Oshmyan.
- Issue #20912: Now directories added to ZIP file have correct Unix and MS-DOS - Issue #20912: Now directories added to ZIP file have correct Unix and MS-DOS
directory attributes. directory attributes.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment