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 shelve.open and dbm.open to support path-like objects #11881

Merged
merged 9 commits into from May 12, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented May 9, 2024

Finally os.fsencode is called on filename argument here: https://github.com/python/cpython/blob/c0d257cc69a943d2c211fe7ad54e706f1085ba1a/Lib/dbm/__init__.py#L112

Which has this type:

def fsencode(filename: StrOrBytesPath) -> bytes: ...

Closes #11856

@sobolevn sobolevn changed the title Update shelve.open to support path-like objects Update shelve.open and dbm.open to support path-like objects May 9, 2024
@sobolevn sobolevn marked this pull request as ready for review May 9, 2024 17:03

This comment has been minimized.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, I think we need to change the other dbm modules as well? (They also accept StrOrBytesPath because of PyUnicode_FSConverter)

@sobolevn
Copy link
Member Author

Sure, done.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

According to the docs, this change was introduced in Python 3.11, so we need to version guard it.

This comment has been minimized.

This comment has been minimized.

@srittau srittau requested a review from hauntsaninja May 10, 2024 09:25
stdlib/shelve.pyi Outdated Show resolved Hide resolved
Copy link
Contributor

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

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thank you!

@hauntsaninja hauntsaninja merged commit 5829e3b into main May 12, 2024
54 checks passed
@hauntsaninja hauntsaninja deleted the sobolevn-patch-1 branch May 12, 2024 20:31
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.

False positive for python stdlib shelve.open()
3 participants