GH-118289: Fix handling of non-directories in posixpath.realpath()#120127
GH-118289: Fix handling of non-directories in posixpath.realpath()#120127barneygale merged 4 commits intopython:mainfrom
posixpath.realpath()#120127Conversation
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!) |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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 <barney.gale@gmail.com>
|
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
NotADirectoryErrorif we encounter a non-directory while we still have path parts left to process.We use a
part_countvariable rather thanlen(rest)because thereststack also contains markers for unresolved symlinks.os.path.realpath('notadir/', strict=True)doesn't raise #118289