# HG changeset patch # Parent b466fd273625560232a3b966757d916777a0f164 diff --git a/Lib/pathlib.py b/Lib/pathlib.py --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -64,10 +64,10 @@ if sep in rel: for x in reversed(rel.split(sep)): if x and x != '.': - parsed.append(sys.intern(x)) + parsed.append(sys.intern(x) if type(x) is str else x) else: if rel and rel != '.': - parsed.append(sys.intern(rel)) + parsed.append(sys.intern(rel) if type(rel) is str else rel) if drv or root: if not drv: # If no drive is present, try to find one in the previous diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -197,6 +197,13 @@ self.assertEqual(P(P('a'), 'b'), P('a/b')) self.assertEqual(P(P('a'), P('b')), P('a/b')) + def test_constructor_subclass(self): + P = self.cls + StrSubclass = type("StrSubclass", (str,), {}) + self.assertEqual(P(StrSubclass('a')), P('a')) + self.assertEqual(P(StrSubclass('a/b')), P('a/b')) + self.assertEqual(P(StrSubclass('/a/b')), P('/a/b')) + def test_join_common(self): P = self.cls p = P('a/b')