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

bpo-40943: PY_SSIZE_T_CLEAN required for '#' formats #20784

Merged
merged 1 commit into from Jun 19, 2020
Merged

bpo-40943: PY_SSIZE_T_CLEAN required for '#' formats #20784

merged 1 commit into from Jun 19, 2020

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 10, 2020

The PY_SSIZE_T_CLEAN macro must now be defined to use
PyArg_ParseTuple() and Py_BuildValue() "#" formats: "es#", "et#",
"s#", "u#", "y#", "z#", "U#" and "Z#". See the PEP 353.

https://bugs.python.org/issue40943

@vstinner
Copy link
Member Author

@methane @serhiy-storchaka: The feature is deprecated in Python 3.8 and Python 3.9. Are you ok to drop it now? Would you mind to review my PR?

@serhiy-storchaka
Copy link
Member

To compensate the shorter release cycle we should use longer deprecation period. Also, breaking changes in the C API have higher bar than breaking changes in Python code. Although I don't think that it will cause severe troubles in this case, because it is easy to write code which works with all supported Python versions, up to very old ones. But 2 years is just too little.

Python/getargs.c Outdated Show resolved Hide resolved
Doc/whatsnew/3.10.rst Show resolved Hide resolved
@vstinner
Copy link
Member Author

To compensate the shorter release cycle we should use longer deprecation period. Also, breaking changes in the C API have higher bar than breaking changes in Python code. Although I don't think that it will cause severe troubles in this case, because it is easy to write code which works with all supported Python versions, up to very old ones. But 2 years is just too little.

@benjaminp and @brettcannon plan to update https://www.python.org/dev/peps/pep-0387/ to require 2 releases instead of 1 between the addition of DeprecationWarning and the removal of the feature, since Python release cycle is now 12 months instead of 18 months (https://www.python.org/dev/peps/pep-0602/).

But here, the warning is already in 2 releases: Python 3.8 and Python 3.9, no?

Note: I would prefer to make such incompatible changes at the beginning of the development cycle, to have more chances to discover issues in third party projects. So we will have more time to decide if the incompatible change must wait longer and so be reverted.

The PY_SSIZE_T_CLEAN macro must now be defined to use
PyArg_ParseTuple() and Py_BuildValue() "#" formats: "es#", "et#",
"s#", "u#", "y#", "z#", "U#" and "Z#". See the PEP 353.

Update _testcapi.test_buildvalue_issue38913().
@vstinner
Copy link
Member Author

I checked Cython and lxml.

Cython always generate #define PY_SSIZE_T_CLEAN. So all C extensions built by Cython are not affected by the change.

lxml test suite pass with this change (ignoring getiterator errors, unrelated to this PR).

@vstinner
Copy link
Member Author

@serhiy-storchaka: I completed my PR to also change Py_BuildValue(). Would you mind to review the updated PR?

@vstinner
Copy link
Member Author

If @serhiy-storchaka doesn't reply, I plan to merge this PR at the end of the week (friday).

@vstinner vstinner merged commit 37bb289 into python:master Jun 19, 2020
@vstinner vstinner deleted the ssize_t_clean branch June 19, 2020 09:45
@vstinner
Copy link
Member Author

Thanks for the review @methane! I prefer to merge such incompatible change at the beginning of 3.10 dev cycle.

fasih pushed a commit to fasih/cpython that referenced this pull request Jun 29, 2020
The PY_SSIZE_T_CLEAN macro must now be defined to use
PyArg_ParseTuple() and Py_BuildValue() "#" formats: "es#", "et#",
"s#", "u#", "y#", "z#", "U#" and "Z#". See the PEP 353.

Update _testcapi.test_buildvalue_issue38913().
arun-mani-j pushed a commit to arun-mani-j/cpython that referenced this pull request Jul 21, 2020
The PY_SSIZE_T_CLEAN macro must now be defined to use
PyArg_ParseTuple() and Py_BuildValue() "#" formats: "es#", "et#",
"s#", "u#", "y#", "z#", "U#" and "Z#". See the PEP 353.

Update _testcapi.test_buildvalue_issue38913().
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

5 participants