Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-82367: Use FindFirstFile Win32 API in ntpath.realpath() #110298

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

Merged

Conversation

moonsikpark
Copy link
Contributor

@moonsikpark moonsikpark commented Oct 3, 2023

ntpath.realpath() breaks out of traversing a series of paths where a (handled) ERROR_ACCESS_DENIED or ERROR_SHARING_VIOLATION occurs.

Using FindFirstFile Win32 API, we can query their real name to correct the case and also resolve MS-DOS (also called 8.3) style file names such as C:\\LONGFI~1.TXT.


📚 Documentation preview 📚: https://cpython-previews--110298.org.readthedocs.build/

Copy link
Member

@zware zware left a comment

Choose a reason for hiding this comment

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

A few documentation nits, but mostly this looks pretty good to me. It will need approval from either @zooba or @eryksun before I'd be comfortable merging it, though.

@zware zware requested review from eryksun and zooba October 3, 2023 17:28
@zooba
Copy link
Member

zooba commented Oct 3, 2023

The code change looks great to me. Awesome job!

With Zach's requested doc changes, I think this is good to merge.

@moonsikpark moonsikpark force-pushed the gh-82367-use-findfirstfile-in-nt-realpath branch from 2c49ffc to 4590347 Compare October 4, 2023 11:38
moonsikpark added a commit to moonsikpark/cpython that referenced this pull request Oct 4, 2023
…ython#110298)

* Use `FindFirstFile` Win32 API to fix a bug where `ntpath.realpath()`
breaks out of traversing a series of paths where a (handled)
`ERROR_ACCESS_DENIED` or `ERROR_SHARING_VIOLATION` occurs.
* Update docs to reflect that `ntpath.realpath()` eliminates MS-DOS
style names.
@moonsikpark moonsikpark force-pushed the gh-82367-use-findfirstfile-in-nt-realpath branch from 4590347 to f675a4f Compare October 4, 2023 11:50
@ghost
Copy link

ghost commented Oct 4, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

moonsikpark added a commit to moonsikpark/cpython that referenced this pull request Oct 4, 2023
…ython#110298)

* Use `FindFirstFile` Win32 API to fix a bug where `ntpath.realpath()`
breaks out of traversing a series of paths where a (handled)
`ERROR_ACCESS_DENIED` or `ERROR_SHARING_VIOLATION` occurs.
* Update docs to reflect that `ntpath.realpath()` eliminates MS-DOS
style names.
@moonsikpark moonsikpark force-pushed the gh-82367-use-findfirstfile-in-nt-realpath branch from d88c757 to e17852c Compare October 4, 2023 14:41
Copy link
Contributor

@eryksun eryksun left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you, Moonsik, and thanks also for taking the extra time to make the test more robust.

…ython#110298)

* Use `FindFirstFile` Win32 API to fix a bug where `ntpath.realpath()`
breaks out of traversing a series of paths where a (handled)
`ERROR_ACCESS_DENIED` or `ERROR_SHARING_VIOLATION` occurs.
* Update docs to reflect that `ntpath.realpath()` eliminates MS-DOS
style names.
@moonsikpark moonsikpark force-pushed the gh-82367-use-findfirstfile-in-nt-realpath branch from 1766bc3 to 2b5a29e Compare October 5, 2023 08:38
@zware zware merged commit d33aa18 into python:main Oct 5, 2023
@zware
Copy link
Member

zware commented Oct 5, 2023

Thanks Steve and Eryk for the reviews, and Moonsik for the patch and excellent collaboration!

@moonsikpark moonsikpark deleted the gh-82367-use-findfirstfile-in-nt-realpath branch October 5, 2023 17:10
@moonsikpark moonsikpark restored the gh-82367-use-findfirstfile-in-nt-realpath branch October 6, 2023 02:17
@moonsikpark moonsikpark deleted the gh-82367-use-findfirstfile-in-nt-realpath branch October 6, 2023 02:20
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…ythonGH-110298)

* Use `FindFirstFile` Win32 API to fix a bug where `ntpath.realpath()`
breaks out of traversing a series of paths where a (handled)
`ERROR_ACCESS_DENIED` or `ERROR_SHARING_VIOLATION` occurs.
* Update docs to reflect that `ntpath.realpath()` eliminates MS-DOS
style names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants