bpo-38878: Fix os.PathLike __subclasshook__ (GH-17336)
Quick subclasshook fix using the same method is being used in collections.abc (up to a certain degree).
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index f44ddba..82c441c 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -4048,6 +4048,14 @@
self.assertRaises(ZeroDivisionError, self.fspath,
FakePath(ZeroDivisionError()))
+ def test_pathlike_subclasshook(self):
+ # bpo-38878: subclasshook causes subclass checks
+ # true on abstract implementation.
+ class A(os.PathLike):
+ pass
+ self.assertFalse(issubclass(FakePath, A))
+ self.assertTrue(issubclass(FakePath, os.PathLike))
+
def test_pathlike_class_getitem(self):
self.assertIs(os.PathLike[bytes], os.PathLike)