return "<{}.parents>".format(type(self._path).__name__)
-class PurePath(object):
+class PurePath(os.PathLike):
"""Base class for manipulating paths without I/O.
PurePath represents a filesystem path and offers operations which
return False
return True
-# Can't subclass os.PathLike from PurePath and keep the constructor
-# optimizations in PurePath.__slots__.
-os.PathLike.register(PurePath)
-
class PurePosixPath(PurePath):
"""PurePath subclass for non-Windows systems.
def test_pathlike_class_getitem(self):
self.assertIsInstance(os.PathLike[bytes], types.GenericAlias)
+ def test_pathlike_subclass_slots(self):
+ class A(os.PathLike):
+ __slots__ = ()
+ def __fspath__(self):
+ return ''
+ self.assertFalse(hasattr(A(), '__dict__'))
class TimesTests(unittest.TestCase):
def test_times(self):