Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6b89ecc
gh-88569: add `os.path.isreserved()`
barneygale Jul 31, 2022
3e08e4a
Fix tests
barneygale Jul 31, 2022
49ba439
Remove implementation in `genericpath`
barneygale Jul 31, 2022
238b3e3
Apply suggestions from code review
barneygale Aug 9, 2022
f647502
Apply suggestions from code review
barneygale Aug 10, 2022
f07c7ad
Remove tests for pathlib.PurePath.is_reserved().
barneygale Aug 10, 2022
dc857c9
Speed up isreserved('.') and '..'
barneygale Aug 12, 2022
f0fd2c8
Note change to algorithm in pathlib docs.
barneygale Aug 12, 2022
3b51db8
Update Lib/ntpath.py
barneygale Aug 12, 2022
06cb428
Update Doc/library/os.path.rst
barneygale Aug 13, 2022
79c0be4
Update Lib/posixpath.py
barneygale Aug 13, 2022
0a0db6a
Restore `os.fspath()` call in `posixpath.isreserved()`
barneygale Aug 16, 2022
7145b86
Apply suggestions from code review
barneygale Aug 23, 2022
9f74b64
posixpath.isreserved(): return True for paths with NUL characters
barneygale Aug 23, 2022
91b2bb3
ntpath.isreserved(): minor tweaks
barneygale Aug 23, 2022
e6aff58
ntpath.isreserved(): restore initial splitdrive() call
barneygale Aug 23, 2022
e6a2c0b
ntpath.isreserved(): avoid calling `splitdrive()` repeatedly.
barneygale Aug 23, 2022
14dde15
Update Lib/ntpath.py
barneygale Aug 23, 2022
fab274a
Add `isreservedname()` for discussion.
barneygale Aug 23, 2022
936dcc8
Apply suggestions from code review
barneygale Aug 23, 2022
3fb127f
Undo posixpath changes
barneygale Jan 8, 2024
002d951
Merge branch 'main' into os-path-isreserved
barneygale Jan 8, 2024
c8ed711
Update version numbers.
barneygale Jan 8, 2024
c772b25
Fix syntax, whitespace.
barneygale Jan 8, 2024
3fbef57
Make `isreservedname()` private
barneygale Jan 8, 2024
4b34274
Update Lib/ntpath.py
barneygale Jan 8, 2024
a877677
Tighten up `PurePath.is_reserved()` exception handling.
barneygale Jan 8, 2024
3721c8c
Use `str(self)` to support non-os.PathLike implementations.
barneygale Jan 8, 2024
b905d2f
Deprecate `pathlib.PurePath.is_reserved()`
barneygale Jan 8, 2024
2756ffb
Add note about approximate and changing Windows rules; remove doctest.
barneygale Jan 8, 2024
c03c672
Update Doc/library/os.path.rst
barneygale Jan 8, 2024
4085ff5
Update what's new.
barneygale Jan 8, 2024
b4b3d0b
Mention deprecation in NEWS
barneygale Jan 8, 2024
9e2d21f
Address review feedback
barneygale Jan 8, 2024
44c37cb
Point to `os.path.isreserved()` in whatsnew deprecation notices.
barneygale Jan 8, 2024
f9033b3
Merge branch 'main' into os-path-isreserved
barneygale Jan 8, 2024
efb7681
Merge branch 'main' into os-path-isreserved
barneygale Jan 14, 2024
e398c3f
Address review feedback
barneygale Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove tests for pathlib.PurePath.is_reserved().
These have been moved to test_ntpath / test_posixpath.
  • Loading branch information
barneygale committed Aug 10, 2022
commit f07c7ad0d529601fa6fbeb0fe1232dac30d0322f
42 changes: 0 additions & 42 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,6 @@ def test_is_absolute(self):
self.assertTrue(P('//a').is_absolute())
self.assertTrue(P('//a/b').is_absolute())

def test_is_reserved(self):
P = self.cls
self.assertIs(False, P('').is_reserved())
self.assertIs(False, P('/').is_reserved())
self.assertIs(False, P('/foo/bar').is_reserved())
self.assertIs(False, P('/dev/con/PRN/NUL').is_reserved())

def test_join(self):
P = self.cls
p = P('//a')
Expand Down Expand Up @@ -1284,41 +1277,6 @@ def test_div(self):
self.assertEqual(p / 'c:x/y', P('C:/a/b/x/y'))
self.assertEqual(p / 'c:/x/y', P('C:/x/y'))

def test_is_reserved(self):
P = self.cls
self.assertIs(False, P('').is_reserved())
self.assertIs(False, P('/').is_reserved())
self.assertIs(False, P('/foo/bar').is_reserved())
# UNC paths are never reserved.
self.assertIs(False, P('//my/share/nul/con/aux').is_reserved())
# Case-insensitive DOS-device names are reserved.
self.assertIs(True, P('nul').is_reserved())
self.assertIs(True, P('aux').is_reserved())
self.assertIs(True, P('prn').is_reserved())
self.assertIs(True, P('con').is_reserved())
self.assertIs(True, P('conin$').is_reserved())
self.assertIs(True, P('conout$').is_reserved())
# COM/LPT + 1-9 or + superscript 1-3 are reserved.
self.assertIs(True, P('COM1').is_reserved())
self.assertIs(True, P('LPT9').is_reserved())
self.assertIs(True, P('com\xb9').is_reserved())
self.assertIs(True, P('com\xb2').is_reserved())
self.assertIs(True, P('lpt\xb3').is_reserved())
# DOS-device name mataching ignores characters after a dot or
# a colon and also ignores trailing spaces.
self.assertIs(True, P('NUL.txt').is_reserved())
self.assertIs(True, P('PRN ').is_reserved())
self.assertIs(True, P('AUX .txt').is_reserved())
self.assertIs(True, P('COM1:bar').is_reserved())
self.assertIs(True, P('LPT9 :bar').is_reserved())
# DOS-device names are only matched at the beginning
# of a path component.
self.assertIs(False, P('bar.com9').is_reserved())
self.assertIs(False, P('bar.lpt9').is_reserved())
# Only the last path component matters.
self.assertIs(True, P('c:/baz/con/NUL').is_reserved())
self.assertIs(False, P('c:/NUL/con/baz').is_reserved())

class PurePathTest(_BasePurePathTest, unittest.TestCase):
cls = pathlib.PurePath

Expand Down