-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-118289: Fix handling of non-directories in posixpath.realpath()
#120127
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
Conversation
In strict mode, raise `NotADirectoryError` if we encounter a non-directory while we still have path parts left to process. We use a `part_count` variable rather than `len(rest)` because the `rest` stack also contains markers for unresolved symlinks.
Follow-up to #118290, where I messed up a rebase and notified everyone (whoops!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
How does it work on Windows? Could you add generic tests for these cases?
This comment was marked as outdated.
This comment was marked as outdated.
Thanks for the review, Serhiy. Playing around with this in Windows, it seems that |
os.path.realpath()
posixpath.realpath()
Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @barneygale, I could not cleanly backport this to
|
….realpath()` (pythonGH-120127) In strict mode, raise `NotADirectoryError` if we encounter a non-directory while we still have path parts left to process. We use a `part_count` variable rather than `len(rest)` because the `rest` stack also contains markers for unresolved symlinks.. (cherry picked from commit fd4b545) Co-authored-by: Barney Gale <[email protected]>
GH-126815 is a backport of this pull request to the 3.13 branch. |
…ath()` (GH-120127) (#126815) In strict mode, raise `NotADirectoryError` if we encounter a non-directory while we still have path parts left to process. We use a `part_count` variable rather than `len(rest)` because the `rest` stack also contains markers for unresolved symlinks. (cherry picked from commit fd4b545)
…th()` (python#120127) In strict mode, raise `NotADirectoryError` if we encounter a non-directory while we still have path parts left to process. We use a `part_count` variable rather than `len(rest)` because the `rest` stack also contains markers for unresolved symlinks.
…th()` (python#120127) In strict mode, raise `NotADirectoryError` if we encounter a non-directory while we still have path parts left to process. We use a `part_count` variable rather than `len(rest)` because the `rest` stack also contains markers for unresolved symlinks.
In strict mode, raise
NotADirectoryError
if we encounter a non-directory while we still have path parts left to process.We use a
part_count
variable rather thanlen(rest)
because therest
stack also contains markers for unresolved symlinks.os.path.realpath('notadir/', strict=True)
doesn't raise #118289