GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — gh-132629: Deprecate acception out of range values for unsigned integers in PyArg_Parse by serhiy-storchaka · Pull Request #132630 · python/cpython Conversation
|
|
This is not a blocker. But the sooner we add warnings, the sooner we can turn them into errors. Recently, you and me added many uses of unsigned integer converters in the socket addresses parsing code. This fixed errors, and allowed to pass values that exceed the limit of corresponding signed integer type, but made the new code more error prone, because passing value that exceeds the limit of an unsigned integer type does not lead to exception. This is the main reason I created that PR now. The idea I proposed a year ago: capi-workgroup/api-evolution#49. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| the maximal value the corresponding C type or less than | ||
| the minimal value for the corresponding signed integer type | ||
| is now deprecated. | ||
| (Contributed by Serhiy Storchaka in :gh:`132629`.) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You should move this entry to Doc/whatsnew/3.15.rst.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| {{{{ | ||
| unsigned long ival = PyLong_AsUnsignedLongMask({argname}); | ||
| if (ival == (unsigned long)-1 && PyErr_Occurred()) {{{{ | ||
| Py_ssize_t _bytes = PyLong_AsNativeBytes({argname}, &{paramname}, sizeof(unsigned char), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you factorize this code? It's copied 4 times. For example, write a function which returns this template, with an argument: the sizeof() argument.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actually, it is not the exactly the same. For unsigned long and unsigned long long it does additional check (historically).
But well, it can be factorized, and with recent changes in Argument Clinic, even more code can be factorized.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM, event if I would prefer to also emit deprecation warnings for (any) negative value for unsigned types.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
… integers in PyArg_Parse (pythonGH-132630) For unsigned integer formats in the PyArg_Parse* functions, accepting Python integers with value that is larger than the maximal value the corresponding C type or less than the minimal value for the corresponding signed integer type is now deprecated.
… integers in PyArg_Parse (pythonGH-132630) For unsigned integer formats in the PyArg_Parse* functions, accepting Python integers with value that is larger than the maximal value the corresponding C type or less than the minimal value for the corresponding signed integer type is now deprecated.
… integers in PyArg_Parse (pythonGH-132630) For unsigned integer formats in the PyArg_Parse* functions, accepting Python integers with value that is larger than the maximal value the corresponding C type or less than the minimal value for the corresponding signed integer type is now deprecated.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.