Skip to content

realpath(..., strict=ALLOW_MISSING) can unexpectedly succeed on Windows #135122

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

Open
serhiy-storchaka opened this issue Jun 4, 2025 · 2 comments
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jun 4, 2025

Bug report

In new tests added for #117562 I noticed that os.path.realpath('file1/file2', strict=os.path.ALLOW_MISSING) returns 'file1/file2' when file file1 exist on Windows.

On Posix you will get NotADirectoryError here, but Windows raises ALLOW_MISSING if the intermediate path is a file instead of directory, and it will be ignored with ALLOW_MISSING.

It is expected that if realpath(..., strict=ALLOW_MISSING) does not fail, you can simply create intermediate directories or the final file/directory. At least on Posix. But on Windows it will always fail, because there is already a file here.

cc @encukou

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error OS-windows 3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes labels Jun 4, 2025
@serhiy-storchaka serhiy-storchaka changed the title realpath(..., strict=ALLOW_MISSING) can unexpectedly success on Windows realpath(..., strict=ALLOW_MISSING) can unexpectedly succeed on Windows Jun 4, 2025
@encukou
Copy link
Member

encukou commented Jun 4, 2025

Thanks for the catch! I'd call that a bug (but not a security issue).

@serhiy-storchaka
Copy link
Member Author

At least, such "gotcha" could be documented. I don't know whether we can detect and change this behavior, or leave it as a Windows peculiarity.

@picnixz picnixz added the extension-modules C modules in the Modules dir label Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy