summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorBar Harel <bzvi7919@gmail.com>2019-12-22 09:57:27 (GMT)
committerIvan Levkivskyi <levkivskyi@gmail.com>2019-12-22 09:57:27 (GMT)
commiteae87e3e4e0cb9a0ce10c2e101acb6995d79e09c (patch)
tree29c538b5b8708fe4410537ea5b81e1d8c08d222a /Lib/os.py
parentf522a6ddb67a238bab5673608111f74ec4e22205 (diff)
downloadcpython-eae87e3e4e0cb9a0ce10c2e101acb6995d79e09c.zip
cpython-eae87e3e4e0cb9a0ce10c2e101acb6995d79e09c.tar.gz
cpython-eae87e3e4e0cb9a0ce10c2e101acb6995d79e09c.tar.bz2
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).
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/os.py b/Lib/os.py
index c901bd1..ca418ed 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -26,6 +26,8 @@ import abc
import sys
import stat as st
+from _collections_abc import _check_methods
+
_names = sys.builtin_module_names
# Note: more names are added to __all__ later.
@@ -1070,7 +1072,9 @@ class PathLike(abc.ABC):
@classmethod
def __subclasshook__(cls, subclass):
- return hasattr(subclass, '__fspath__')
+ if cls is PathLike:
+ return _check_methods(subclass, '__fspath__')
+ return NotImplemented
def __class_getitem__(cls, type):
return cls