mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
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).
This commit is contained in:
parent
f522a6ddb6
commit
eae87e3e4e
3 changed files with 15 additions and 1 deletions
|
@ -4048,6 +4048,14 @@ class TestPEP519(unittest.TestCase):
|
|||
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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue