Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit874a4f7

Browse 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 parent8c96850 commit874a4f7

File tree

5 files changed

+335
-379
lines changed

5 files changed

+335
-379
lines changed

‎Lib/test/test_genericpath.py‎

Lines 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+
ifself.pathmoduleisnotgenericpath:
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‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,27 @@ def test_isfile_driveletter(self):
976976
raiseunittest.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+
deftest_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+
deftest_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
deftest_con_device(self):
9811002
self.assertFalse(os.path.isfile(r"\\.\CON"))
Lines 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‎

Lines changed: 56 additions & 68 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp