Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 874a4f7

Browse filesBrowse files
authored
gh-118507 : Refactor ntpath native functions (gh-119381)
This refactoring will make future backports easier without changing behaviours, apart from correcting a bug when passing a pipe to `ntpath.isfile`.
1 parent 8c96850 commit 874a4f7
Copy full SHA for 874a4f7

File tree

Expand file treeCollapse file tree

5 files changed

+335
-379
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+335
-379
lines changed

‎Lib/test/test_genericpath.py

Copy file name to clipboardExpand all lines: Lib/test/test_genericpath.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def test_exists(self):
135135
self.assertIs(self.pathmodule.exists(filename), False)
136136
self.assertIs(self.pathmodule.exists(bfilename), False)
137137

138+
if self.pathmodule is not genericpath:
139+
self.assertIs(self.pathmodule.lexists(filename), False)
140+
self.assertIs(self.pathmodule.lexists(bfilename), False)
141+
138142
create_file(filename)
139143

140144
self.assertIs(self.pathmodule.exists(filename), True)

‎Lib/test/test_ntpath.py

Copy file name to clipboardExpand all lines: Lib/test/test_ntpath.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,27 @@ def test_isfile_driveletter(self):
976976
raise unittest.SkipTest('SystemDrive is not defined or malformed')
977977
self.assertFalse(os.path.isfile('\\\\.\\' + drive))
978978

979+
@unittest.skipUnless(hasattr(os, 'pipe'), "need os.pipe()")
980+
def test_isfile_anonymous_pipe(self):
981+
pr, pw = os.pipe()
982+
try:
983+
self.assertFalse(ntpath.isfile(pr))
984+
finally:
985+
os.close(pr)
986+
os.close(pw)
987+
988+
@unittest.skipIf(sys.platform != 'win32', "windows only")
989+
def test_isfile_named_pipe(self):
990+
import _winapi
991+
named_pipe = f'//./PIPE/python_isfile_test_{os.getpid()}'
992+
h = _winapi.CreateNamedPipe(named_pipe,
993+
_winapi.PIPE_ACCESS_INBOUND,
994+
0, 1, 0, 0, 0, 0)
995+
try:
996+
self.assertFalse(ntpath.isfile(named_pipe))
997+
finally:
998+
_winapi.CloseHandle(h)
999+
9791000
@unittest.skipIf(sys.platform != 'win32', "windows only")
9801001
def test_con_device(self):
9811002
self.assertFalse(os.path.isfile(r"\\.\CON"))
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :func:`os.path.isfile` on Windows for pipes.

‎Modules/clinic/posixmodule.c.h

Copy file name to clipboardExpand all lines: Modules/clinic/posixmodule.c.h
+56-68Lines changed: 56 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.