changeset: 92595:2ae2ca9d2b66 branch: 2.7 parent: 92588:adac8ba7b1b1 user: Serhiy Storchaka date: Sat Sep 27 18:53:01 2014 +0300 files: Lib/macpath.py Lib/test/test_macpath.py Misc/NEWS description: Issue #9850: Fixed macpath.join() for empty first component. Patch by Oleg Oshmyan. diff -r adac8ba7b1b1 -r 2ae2ca9d2b66 Lib/macpath.py --- a/Lib/macpath.py Fri Sep 26 17:07:39 2014 -0400 +++ b/Lib/macpath.py Sat Sep 27 18:53:01 2014 +0300 @@ -42,7 +42,7 @@ def join(s, *p): path = s for t in p: - if (not s) or isabs(t): + if (not path) or isabs(t): path = t continue if t[:1] == ':': diff -r adac8ba7b1b1 -r 2ae2ca9d2b66 Lib/test/test_macpath.py --- a/Lib/test/test_macpath.py Fri Sep 26 17:07:39 2014 -0400 +++ b/Lib/test/test_macpath.py Sat Sep 27 18:53:01 2014 +0300 @@ -29,6 +29,26 @@ self.assertEqual(split(":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): splitext = macpath.splitext self.assertEqual(splitext(":foo.ext"), (':foo', '.ext')) diff -r adac8ba7b1b1 -r 2ae2ca9d2b66 Misc/NEWS --- a/Misc/NEWS Fri Sep 26 17:07:39 2014 -0400 +++ b/Misc/NEWS Sat Sep 27 18:53:01 2014 +0300 @@ -22,6 +22,9 @@ 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 directory attributes.