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

gh-118507 : Refactornt._path_is*#118755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
zooba merged 44 commits intopython:mainfromnineteendo:refactor-nt._path_is
May 21, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
44 commits
Select commitHold shift + click to select a range
ab76c06
Speedup `ntpath.exists`
nineteendoApr 13, 2024
1c5350d
Update comment
nineteendoApr 13, 2024
d7017ac
📜🤖 Added by blurb_it.
blurb-it[bot]Apr 13, 2024
2963338
Improve `nt_exists()`
nineteendoApr 15, 2024
e833f04
Apply suggestions from code review
nineteendoApr 15, 2024
d0493c2
Revert helper functions
nineteendoApr 15, 2024
4403f4a
Update argument clinic
nineteendoApr 15, 2024
7a9038f
Update 2024-04-13-11-30-09.gh-issue-117841.eW4w_y.rst
nineteendoApr 22, 2024
a6ec86d
Merge branch 'main' into speedup-ntpath.lexists
nineteendoApr 26, 2024
30603f0
Refactor `nt._path_is*`
nineteendoMay 8, 2024
cd7c6d0
Add `nt._path_isjunction`
nineteendoMay 8, 2024
168d299
Fix bug & further refactoring
nineteendoMay 8, 2024
e00df4c
Fix attribute name
nineteendoMay 8, 2024
b31a252
Add test for pipe
nineteendoMay 8, 2024
59e1407
Skip unless `os.pipe` is available
nineteendoMay 8, 2024
76acc0d
📜🤖 Added by blurb_it.
blurb-it[bot]May 8, 2024
2c8e464
Update Modules/posixmodule.c
nineteendoMay 9, 2024
a8bc5f2
Update Modules/posixmodule.c
nineteendoMay 9, 2024
55b6b80
Update Lib/test/test_ntpath.py
nineteendoMay 9, 2024
61a62ce
Fix compilation errors
nineteendoMay 9, 2024
ba79151
Update Modules/posixmodule.c
nineteendoMay 9, 2024
5153413
Merge branch 'refactor-nt._path_is' into speedup-ntpath.lexists
nineteendoMay 9, 2024
01568bb
Merge pull request #1 from nineteendo/speedup-ntpath.lexists
nineteendoMay 9, 2024
07629c6
Merge news entries
nineteendoMay 9, 2024
0fcffb5
Replace ampersand
nineteendoMay 9, 2024
cae7a55
More refactoring
nineteendoMay 13, 2024
cbf0bc4
Update generated code
nineteendoMay 13, 2024
4c0a3f7
Fix path conversion
nineteendoMay 13, 2024
5bf963e
Fix undefined variable
nineteendoMay 13, 2024
71cb7f0
Add helper function
nineteendoMay 13, 2024
24d2749
Apply suggestions from code review
nineteendoMay 13, 2024
6edc3b3
Fix syntax error
nineteendoMay 13, 2024
c6dae2c
Further refactoring
nineteendoMay 13, 2024
05dd20e
Ternary operator
nineteendoMay 13, 2024
2ced928
Fix attributes
nineteendoMay 13, 2024
dfd4196
No inline
nineteendoMay 13, 2024
7a7e942
Apply suggestions from code review
nineteendoMay 13, 2024
50b3612
Update posixmodule.c
nineteendoMay 13, 2024
eab1cb4
Update Modules/posixmodule.c
nineteendoMay 13, 2024
6f6b07b
Update Modules/posixmodule.c
nineteendoMay 13, 2024
0ca58a0
Update posixmodule.c
nineteendoMay 13, 2024
3f1ea76
Update Modules/posixmodule.c
nineteendoMay 13, 2024
222c58a
Update test_ntpath.py
nineteendoMay 16, 2024
6e41cbf
Update Lib/test/test_ntpath.py
nineteendoMay 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
21 changes: 4 additions & 17 deletionsLib/ntpath.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -288,21 +288,6 @@ def dirname(p):
return split(p)[0]


# Is a path a junction?

if hasattr(os.stat_result, 'st_reparse_tag'):
def isjunction(path):
"""Test whether a path is a junction"""
try:
st = os.lstat(path)
except (OSError, ValueError, AttributeError):
return False
return st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
else:
# Use genericpath.isjunction as imported above
pass


# Is a path a mount point?
# Any drive letter root (eg c:\)
# Any share UNC (eg \\server\share)
Expand DownExpand Up@@ -911,13 +896,15 @@ def commonpath(paths):


try:
# The isdir(), isfile(), islink()andexists() implementations in
# genericpath use os.stat(). This is overkill on Windows. Use simpler
# The isdir(), isfile(), islink(), exists()andlexists() implementations
#ingenericpath use os.stat(). This is overkill on Windows. Use simpler
# builtin functions if they are available.
from nt import _path_isdir as isdir
from nt import _path_isfile as isfile
from nt import _path_islink as islink
from nt import _path_isjunction as isjunction
from nt import _path_exists as exists
from nt import _path_lexists as lexists
except ImportError:
# Use genericpath.* as imported above
pass
Expand Down
16 changes: 9 additions & 7 deletionsLib/test/test_genericpath.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -135,6 +135,9 @@ def test_exists(self):
self.assertIs(self.pathmodule.exists(filename), False)
self.assertIs(self.pathmodule.exists(bfilename), False)

self.assertIs(self.pathmodule.lexists(filename), False)
self.assertIs(self.pathmodule.lexists(bfilename), False)

create_file(filename)

self.assertIs(self.pathmodule.exists(filename), True)
Expand All@@ -145,14 +148,13 @@ def test_exists(self):
self.assertIs(self.pathmodule.exists(filename + '\x00'), False)
self.assertIs(self.pathmodule.exists(bfilename + b'\x00'), False)

if self.pathmodule is not genericpath:
self.assertIs(self.pathmodule.lexists(filename), True)
self.assertIs(self.pathmodule.lexists(bfilename), True)
self.assertIs(self.pathmodule.lexists(filename), True)
self.assertIs(self.pathmodule.lexists(bfilename), True)

self.assertIs(self.pathmodule.lexists(filename + '\udfff'), False)
self.assertIs(self.pathmodule.lexists(bfilename + b'\xff'), False)
self.assertIs(self.pathmodule.lexists(filename + '\x00'), False)
self.assertIs(self.pathmodule.lexists(bfilename + b'\x00'), False)
self.assertIs(self.pathmodule.lexists(filename + '\udfff'), False)
self.assertIs(self.pathmodule.lexists(bfilename + b'\xff'), False)
self.assertIs(self.pathmodule.lexists(filename + '\x00'), False)
self.assertIs(self.pathmodule.lexists(bfilename + b'\x00'), False)

@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
@unittest.skipIf(is_emscripten, "Emscripten pipe fds have no stat")
Expand Down
25 changes: 25 additions & 0 deletionsLib/test/test_ntpath.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1095,6 +1095,27 @@ def test_isfile_driveletter(self):
raise unittest.SkipTest('SystemDrive is not defined or malformed')
self.assertFalse(os.path.isfile('\\\\.\\' + drive))

@unittest.skipUnless(hasattr(os, 'pipe'), "need os.pipe()")
def test_isfile_anonymous_pipe(self):
pr, pw = os.pipe()
try:
self.assertFalse(ntpath.isfile(pr))
finally:
os.close(pr)
os.close(pw)

@unittest.skipIf(sys.platform != 'win32', "windows only")
def test_isfile_named_pipe(self):
import _winapi
named_pipe = f'//./PIPE/python_isfile_test_{os.getpid()}'
h = _winapi.CreateNamedPipe(named_pipe,
_winapi.PIPE_ACCESS_INBOUND,
0, 1, 0, 0, 0, 0)
try:
self.assertFalse(ntpath.isfile(named_pipe))
finally:
_winapi.CloseHandle(h)

@unittest.skipIf(sys.platform != 'win32', "windows only")
def test_con_device(self):
self.assertFalse(os.path.isfile(r"\\.\CON"))
Expand All@@ -1114,8 +1135,12 @@ def test_fast_paths_in_use(self):
self.assertFalse(inspect.isfunction(os.path.isfile))
self.assertTrue(os.path.islink is nt._path_islink)
self.assertFalse(inspect.isfunction(os.path.islink))
self.assertTrue(os.path.isjunction is nt._path_isjunction)
self.assertFalse(inspect.isfunction(os.path.isjunction))
self.assertTrue(os.path.exists is nt._path_exists)
self.assertFalse(inspect.isfunction(os.path.exists))
self.assertTrue(os.path.lexists is nt._path_lexists)
self.assertFalse(inspect.isfunction(os.path.lexists))

@unittest.skipIf(os.name != 'nt', "Dev Drives only exist on Win32")
def test_isdevdrive(self):
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Speedup :func:`os.path.isjunction` and :func:`os.path.lexists` on Windows with a native implementation.
156 changes: 124 additions & 32 deletionsModules/clinic/posixmodule.c.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp