-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor nt._path_is*
& nt._path_[l]exists
#118507
Comments
Eryk, do you have any ideas to clean them up (besides the simpler error handling)? |
This comment was marked as resolved.
This comment was marked as resolved.
Good start, we probably need a |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Did you speed something up, because it's only 3 lines less than the old code. |
My goal was to remove duplicated code and divide the work into two separate operations that can be understood and modified independently, written in a way that I think is easy to understand. This reduces the maintenance burden. I also added internal support for checking for mount points, in case we implement I added a >>> pr, pw = os.pipe()
>>> threading.Thread(target=os.read, args=(pr, 1)).start()
>>> os.path.isfile(pr)
^C Also, given the system's named-pipe filesystem (NPFS) support for basic file information (anonymous pipes are also in NPFS, but they're like unlinked open files in POSIX), the >>> pr, pw = os.pipe()
>>> os.path.isfile(pr)
True |
OK, that explains why the code isn't much shorter. I added a test for the second issue. The first one seems difficult to test. |
…r other cases (pythonGH-118755) (cherry picked from commit b641825) Co-authored-by: Nice Zombies <[email protected]>
…r cases (GH-118755) (cherry picked from commit b641825) Co-authored-by: Nice Zombies <[email protected]>
…r other cases (pythonGH-118755)
This refactoring will make future backports easier without changing behaviours, apart from correcting a bug when passing a pipe to `ntpath.isfile`.
…r other cases (pythonGH-118755)
Feature or enhancement
Proposal:
Quoting @eryksun:
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
ntpath.lexists
#117842Linked PRs
nt._path_is*
#118755nt._path_is*
to improve applicability for other cases (GH-118755) #119360ntpath.isfile
for pipes. #119381ntpath.isjunction()
&ntpath.lexists()
with native helpers (GH-118755) #119420The text was updated successfully, but these errors were encountered: