@@ -707,11 +707,7 @@ def __new__(cls, *args, **kwargs):
707
707
warnings ._deprecated ("pathlib.PurePath(**kwargs)" , msg , remove = (3 , 14 ))
708
708
if cls is Path :
709
709
cls = WindowsPath if os .name == 'nt' else PosixPath
710
- self = cls ._from_parts (args )
711
- if self ._flavour is not os .path :
712
- raise NotImplementedError ("cannot instantiate %r on your system"
713
- % (cls .__name__ ,))
714
- return self
710
+ return cls ._from_parts (args )
715
711
716
712
def _make_child_relpath (self , part ):
717
713
# This is an optimization used for dir walking. `part` must be
@@ -1261,9 +1257,19 @@ class PosixPath(Path, PurePosixPath):
1261
1257
"""
1262
1258
__slots__ = ()
1263
1259
1260
+ if os .name == 'nt' :
1261
+ def __new__ (cls , * args , ** kwargs ):
1262
+ raise NotImplementedError (
1263
+ f"cannot instantiate { cls .__name__ !r} on your system" )
1264
+
1264
1265
class WindowsPath (Path , PureWindowsPath ):
1265
1266
"""Path subclass for Windows systems.
1266
1267
1267
1268
On a Windows system, instantiating a Path should return this object.
1268
1269
"""
1269
1270
__slots__ = ()
1271
+
1272
+ if os .name != 'nt' :
1273
+ def __new__ (cls , * args , ** kwargs ):
1274
+ raise NotImplementedError (
1275
+ f"cannot instantiate { cls .__name__ !r} on your system" )
0 commit comments