Skip to content

bpo-36127: Fix compiler warning in _PyArg_UnpackKeywords().#12353

Merged
serhiy-storchaka merged 1 commit intopython:masterfrom
serhiy-storchaka:getargs_warn2
Mar 16, 2019
Merged

bpo-36127: Fix compiler warning in _PyArg_UnpackKeywords().#12353
serhiy-storchaka merged 1 commit intopython:masterfrom
serhiy-storchaka:getargs_warn2

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Mar 15, 2019

Since nargs <= maxpos, nargs can be casted to int without lost.

https://bugs.python.org/issue36127


/* copy keyword args using kwtuple to drive process */
for (i = Py_MAX(nargs, posonly); i < maxargs; i++) {
for (i = Py_MAX((int)nargs, posonly); i < maxargs; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that this code is safe is nargs > INT_MAX. (int)(INT_MAX+1) gives 0, no?

Maybe write something like:

i = (nargs < INT_MAX) ? (int)nargs : INT_MAX;
i = Py_MAX(i, posonly);

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