Skip to content

Commit 3d27707

Browse files
committed
Remove flavour.is_supported
1 parent 66f5453 commit 3d27707

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Lib/pathlib.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ class _WindowsFlavour(_Flavour):
5757

5858
has_drv = True
5959

60-
is_supported = (os.name == 'nt')
61-
6260
def casefold(self, s):
6361
return s.lower()
6462

@@ -69,8 +67,6 @@ def casefold_parts(self, parts):
6967
class _PosixFlavour(_Flavour):
7068
has_drv = False
7169

72-
is_supported = (os.name != 'nt')
73-
7470
def casefold(self, s):
7571
return s
7672

@@ -788,6 +784,7 @@ class PurePosixPath(PurePath):
788784
"""
789785
_flavour = _posix_flavour
790786
_pathmod = posixpath
787+
_supported = (os.name != 'nt')
791788
_case_insensitive = False
792789
__slots__ = ()
793790

@@ -828,6 +825,7 @@ class PureWindowsPath(PurePath):
828825
"""
829826
_flavour = _windows_flavour
830827
_pathmod = ntpath
828+
_supported = (os.name == 'nt')
831829
_case_insensitive = True
832830
_drive_letters = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
833831
_ext_namespace_prefix = '\\\\?\\'
@@ -940,11 +938,10 @@ class Path(PurePath):
940938
def __new__(cls, *args, **kwargs):
941939
if cls is Path:
942940
cls = WindowsPath if os.name == 'nt' else PosixPath
943-
self = cls._from_parts(args)
944-
if not self._flavour.is_supported:
941+
elif not cls._supported:
945942
raise NotImplementedError("cannot instantiate %r on your system"
946943
% (cls.__name__,))
947-
return self
944+
return cls._from_parts(args)
948945

949946
def _make_child_relpath(self, part):
950947
# This is an optimization used for dir walking. `part` must be

Lib/test/test_pathlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2400,7 +2400,7 @@ def test_concrete_class(self):
24002400
self.assertIs(type(p),
24012401
pathlib.WindowsPath if os.name == 'nt' else pathlib.PosixPath)
24022402

2403-
def test_unsupported_flavour(self):
2403+
def test_unsupported_type(self):
24042404
if os.name == 'nt':
24052405
self.assertRaises(NotImplementedError, pathlib.PosixPath)
24062406
else:

0 commit comments

Comments
 (0)