mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
Issue #23466: Raised OverflowError if %c argument is out of range.
This commit is contained in:
parent
45ec3288d0
commit
41525e31a5
2 changed files with 14 additions and 9 deletions
|
@ -496,10 +496,15 @@ byte_converter(PyObject *arg, char *p)
|
|||
ival = PyLong_AsLongAndOverflow(iobj, &overflow);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (!overflow && 0 <= ival && ival <= 255) {
|
||||
*p = (char)ival;
|
||||
return 1;
|
||||
if (!overflow && ival == -1 && PyErr_Occurred())
|
||||
goto onError;
|
||||
if (overflow || !(0 <= ival && ival <= 255)) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"%c arg not in range(256)");
|
||||
return 0;
|
||||
}
|
||||
*p = (char)ival;
|
||||
return 1;
|
||||
}
|
||||
onError:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue