Skip to content

gh-50333: Deprecate support of non-tuple sequences in PyArg_ParseTuple() #128374

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

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Dec 31, 2024

Non-tuple sequences are deprecated as argument for the "(items)" format unit in PyArg_ParseTuple() and other argument parsing functions if items contains format units which store borrowed buffer or reference (e.g. "s" and "O").

str and bytearray are no longer accepted as valid sequences.


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

…seTuple()

Non-tuple sequences are deprecated as argument for the "(items)" format unit
in PyArg_ParseTuple() and other argument parsing functions if items contains
format units which store borrowed buffer or reference (e.g. "s" and "O").

str and bytearray are no longer accepted as valid sequences.
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

While I understand that "borrowed buffer or reference" reads as "borrowed buffer or borrowed reference", I would advise repeating "borrowed reference" as well.

I haven't looked at te implementation though.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@erlend-aasland
Copy link
Contributor

While I understand that "borrowed buffer or reference" reads as "borrowed buffer or borrowed reference", I would advise repeating "borrowed reference" as well.

In this case, I think we should consider being explicit, rather than worrying about the repeated word.

@serhiy-storchaka
Copy link
Member Author

This didn't cause much controversy when posted on Discourse, so I just merge it. There will be time to tweak or revert it.

@serhiy-storchaka serhiy-storchaka merged commit 0e4cf9c into python:main Apr 8, 2025
42 checks passed
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
…seTuple() (pythonGH-128374)

Non-tuple sequences are deprecated as argument for the "(items)" format unit
in PyArg_ParseTuple() and other argument parsing functions if items contains
format units which store borrowed buffer or reference (e.g. "s" and "O").

str and bytearray are no longer accepted as valid sequences.
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.

4 participants