GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — gh-99547: Add isjunction methods for checking if a path is a junction by csm10495 · Pull Request #99548 · python/cpython Conversation
Contributor
Implementation of gh-99547. This is my first try at getting something into cpython.. so please go easy on me. Thanks!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsThe actual functionality lives in ntpath/posixpath, so just verify the correct function is called and return value is returned …latforms We can only create junctions on windows, thus only test this on win32
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
Code looks good, but we'll also need docs updated (at least the os.path docs and What's New for 3.12) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@zooba is there a wiki or something on which files generate the docs? I had thought maybe it was from the code. Happy to update docs :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Whelp.. doing this on a phone is tough.. reopened |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Eryk Sun <[email protected]>
There was an error while loading. Please reload this page.
Co-authored-by: Eryk Sun <[email protected]>
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
We could eliminate try: is_dir = (entry.is_dir(follow_symlinks=False) and not entry.is_junction()) except OSError: is_dir = False This is relatively cheap. On Windows, both tests use the cached stat info from the directory entry. On POSIX, the To replace if os.path.islink(path) or os.path.isjunction(path): # symlinks to directories are forbidden, see bug #1669 raise OSError("Cannot call rmtree on a symbolic link or junction") However, this calls If |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm not a big fan of needing to call stat again if we don't need to. Part of me thinks that stat objects should have methods similar to pathlib.Path's is_ methods for checking things based on a cached stat. We can kind of cheat to get there with a DirEntry but idk. I mean I know we have some stat IS_ functions but I guess I like methods on objects better than loose functions. Regardless: do we feel as though these optimizations should be part of the current issue or should maybe be a post merge task? I kind of feel as though we're stepping a tiny bit out of the scope of the current task. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't consider the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Replacing
Junctions don't have a POSIX file type other than as a directory, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It's just continually adding things on to the same PR is kind of discouraging for me as a new contributor. I'd greatly prefer having all asks at once (so they can be attacked at once) as opposed to small ones continually given over and over. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Okay. I'm sorry if you feel discouraged. This pull request is outstanding for a new contributor. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@zooba, since your last review there was a minor change to the documentation, and a test was fixed. If that's all okay with you, then this is ready to be merged as soon as Charles says so. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… dir and not a junction across the board
|
Ok i removed _rmtree_is_dir() and replaced its usage with is_dir/is_junction checks. Unit tests pass. If its ok, i'm good with a merge at this point. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Eryk Sun <[email protected]>
|
I wonder if one day is_dir should be updated to return False on OSError internally.. regardless I've updated the implementation to handle that case here. I'll leave that to a separate thread. Updated. If it all passes, i'm still good for merge here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The rationale is in PEP 471, notes on exception handling. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Eryk Sun <[email protected]>
|
Thanks! Great job, and congratulations on your first contribution! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.