[3.8] bpo-38878: Fix os.PathLike __subclasshook__ (GH-17336) (GH-17684)

https://bugs.python.org/issue38878
diff --git a/Lib/os.py b/Lib/os.py
index 52d3f1d..253cad1 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -26,6 +26,8 @@
 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 @@
 
     @classmethod
     def __subclasshook__(cls, subclass):
-        return hasattr(subclass, '__fspath__')
+        if cls is PathLike:
+            return _check_methods(subclass, '__fspath__')
+        return NotImplemented
 
 
 if name == 'nt':