Skip to content
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

GH-118289: Fix handling of non-directories in os.path.realpath() #118290

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Apr 25, 2024

In strict mode, raise NotADirectoryError if a file path is given with a trailing slash or subsequent dot segments.

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 a file path is given with a
trailing slash, or subsequent dot segments.

We use a `part_count` variable rather than `len(rest)` because the `rest`
stack also contains markers for unresolved symlinks.
@barneygale barneygale marked this pull request as ready for review April 25, 2024 18:08
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I support this idea. It may even be considered as a bugfix.

Lib/posixpath.py Outdated Show resolved Hide resolved
Lib/test/test_posixpath.py Outdated Show resolved Hide resolved
Lib/posixpath.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants