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

Update os.path.isdir on Windows Python3.12+ #10751

Closed

Conversation

aminalaee
Copy link
Contributor

@aminalaee aminalaee commented Sep 22, 2023

Following #10748 (comment)
cc @AlexWaygood

Ref: https://github.com/python/cpython/blame/b28ffaa193efc66f46ab90d383279174a11a11d7/Modules/clinic/posixmodule.c.h#L1989

Seems like os.path.isdir has different signature os.path.isdir(path) compared to os.path.isdir(s) in netpath.py, not sure if this was intentional in CPython.

@aminalaee aminalaee force-pushed the python3.12-windows-os-path-isdir branch 2 times, most recently from afafed0 to 9de14dd Compare September 22, 2023 18:55
@github-actions

This comment has been minimized.

@aminalaee aminalaee force-pushed the python3.12-windows-os-path-isdir branch 2 times, most recently from ebc8fb4 to 06d0e14 Compare September 22, 2023 19:12
@aminalaee aminalaee force-pushed the python3.12-windows-os-path-isdir branch from 06d0e14 to b82ffc2 Compare September 22, 2023 19:15
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@aminalaee aminalaee marked this pull request as ready for review September 22, 2023 21:19
@JelleZijlstra
Copy link
Member

This feels unfortunate and maybe should be fixed in CPython instead. Or perhaps the parameter should be made positional-only.

@AlexWaygood
Copy link
Member

AlexWaygood commented Sep 23, 2023

This feels unfortunate and maybe should be fixed in CPython instead. Or perhaps the parameter should be made positional-only.

Yeah, I think one of the two would be the better fix. Kinda the point of os.path is that the module is meant to be an abstraction that's fully cross-platform. So it makes things somewhat awkward when a function in os.path has a different signature on Windows than on other platforms. See #6812, where we had a similar issue, and tackled it by pretending the parameter was positional-only.

Here I think the best solution might be to raise this with CPython. Since the ntpath implementation is new, it seems unlikely to me that they intended to give it a different parameter name to the posix implementation.

@aminalaee
Copy link
Contributor Author

Yeah I think if this was not intentional in CPython, there's still time to change it. I will open an issue now.

@JelleZijlstra
Copy link
Member

The fix was merged into CPython and is planned to go into 3.12 eventually, so I think we shouldn't change anything here. Thanks for uncovering this issue!

@aminalaee aminalaee deleted the python3.12-windows-os-path-isdir branch September 29, 2023 07:19
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.

None yet

3 participants