mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-132987: Support __index__() for "k" and "K" formats in PyArg_Parse (GH-132988)
This commit is contained in:
parent
e714ead7a2
commit
632524a5cb
12 changed files with 51 additions and 30 deletions
|
@ -839,10 +839,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
unsigned long *p = va_arg(*p_va, unsigned long *);
|
||||
HANDLE_NULLABLE;
|
||||
unsigned long ival;
|
||||
if (PyLong_Check(arg))
|
||||
ival = PyLong_AsUnsignedLongMask(arg);
|
||||
else
|
||||
if (!PyIndex_Check(arg)) {
|
||||
return converterr(nullable, "int", arg, msgbuf, bufsize);
|
||||
}
|
||||
ival = PyLong_AsUnsignedLongMask(arg);
|
||||
if (ival == (unsigned long)(long)-1 && PyErr_Occurred()) {
|
||||
RETURN_ERR_OCCURRED;
|
||||
}
|
||||
*p = ival;
|
||||
break;
|
||||
}
|
||||
|
@ -862,10 +865,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
unsigned long long *p = va_arg(*p_va, unsigned long long *);
|
||||
HANDLE_NULLABLE;
|
||||
unsigned long long ival;
|
||||
if (PyLong_Check(arg))
|
||||
ival = PyLong_AsUnsignedLongLongMask(arg);
|
||||
else
|
||||
if (!PyIndex_Check(arg)) {
|
||||
return converterr(nullable, "int", arg, msgbuf, bufsize);
|
||||
}
|
||||
ival = PyLong_AsUnsignedLongLongMask(arg);
|
||||
if (ival == (unsigned long long)(long long)-1 && PyErr_Occurred()) {
|
||||
RETURN_ERR_OCCURRED;
|
||||
}
|
||||
*p = ival;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue