Skip to content

Commit 0897d9d

Browse files
committed
Remove _Flavour, _WindowsFlavour and _PosixFlavour
1 parent 3cf15c6 commit 0897d9d

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

Lib/pathlib.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,6 @@ def _is_wildcard_pattern(pat):
4646
return "*" in pat or "?" in pat or "[" in pat
4747

4848

49-
class _Flavour(object):
50-
"""A flavour implements a particular (platform-specific) set of path
51-
semantics."""
52-
53-
54-
class _WindowsFlavour(_Flavour):
55-
# Reference for Windows paths can be found at
56-
# http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
57-
pass
58-
59-
60-
class _PosixFlavour(_Flavour):
61-
pass
62-
63-
64-
_windows_flavour = _WindowsFlavour()
65-
_posix_flavour = _PosixFlavour()
66-
67-
6849
class _Accessor:
6950
"""An accessor implements a particular (system-specific or not) way of
7051
accessing paths on the filesystem."""
@@ -516,9 +497,9 @@ def _cparts(self):
516497
return self._cached_cparts
517498

518499
def __eq__(self, other):
519-
if not isinstance(other, PurePath):
500+
if not isinstance(other, type(self)):
520501
return NotImplemented
521-
return self._cparts == other._cparts and self._flavour is other._flavour
502+
return self._cparts == other._cparts
522503

523504
def __hash__(self):
524505
try:
@@ -528,22 +509,22 @@ def __hash__(self):
528509
return self._hash
529510

530511
def __lt__(self, other):
531-
if not isinstance(other, PurePath) or self._flavour is not other._flavour:
512+
if not isinstance(other, type(self)):
532513
return NotImplemented
533514
return self._cparts < other._cparts
534515

535516
def __le__(self, other):
536-
if not isinstance(other, PurePath) or self._flavour is not other._flavour:
517+
if not isinstance(other, type(self)):
537518
return NotImplemented
538519
return self._cparts <= other._cparts
539520

540521
def __gt__(self, other):
541-
if not isinstance(other, PurePath) or self._flavour is not other._flavour:
522+
if not isinstance(other, type(self)):
542523
return NotImplemented
543524
return self._cparts > other._cparts
544525

545526
def __ge__(self, other):
546-
if not isinstance(other, PurePath) or self._flavour is not other._flavour:
527+
if not isinstance(other, type(self)):
547528
return NotImplemented
548529
return self._cparts >= other._cparts
549530

@@ -779,7 +760,6 @@ class PurePosixPath(PurePath):
779760
On a POSIX system, instantiating a PurePath should return this object.
780761
However, you can also instantiate it directly on any system.
781762
"""
782-
_flavour = _posix_flavour
783763
_pathmod = posixpath
784764
_supported = (os.name != 'nt')
785765
_case_insensitive = False
@@ -823,7 +803,8 @@ class PureWindowsPath(PurePath):
823803
On a Windows system, instantiating a PurePath should return this object.
824804
However, you can also instantiate it directly on any system.
825805
"""
826-
_flavour = _windows_flavour
806+
# Reference for Windows paths can be found at
807+
# http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
827808
_pathmod = ntpath
828809
_supported = (os.name == 'nt')
829810
_case_insensitive = True

Lib/test/test_pathlib.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class _BasePurePathTest(object):
4545

4646
def setUp(self):
4747
p = self.cls('a')
48-
self.flavour = p._flavour
4948
self.sep = p._pathmod.sep
5049
self.altsep = p._pathmod.altsep
5150

@@ -1290,12 +1289,12 @@ def test_concrete_class(self):
12901289
self.assertIs(type(p),
12911290
pathlib.PureWindowsPath if os.name == 'nt' else pathlib.PurePosixPath)
12921291

1293-
def test_different_flavours_unequal(self):
1292+
def test_different_types_unequal(self):
12941293
p = pathlib.PurePosixPath('a')
12951294
q = pathlib.PureWindowsPath('a')
12961295
self.assertNotEqual(p, q)
12971296

1298-
def test_different_flavours_unordered(self):
1297+
def test_different_types_unordered(self):
12991298
p = pathlib.PurePosixPath('a')
13001299
q = pathlib.PureWindowsPath('a')
13011300
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)