-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
In the function pylong_aslongandoverflow
cpython/Modules/_testlimitedcapi/long.c
Lines 621 to 632 in 3929af5
static PyObject * | |
pylong_aslongandoverflow(PyObject *module, PyObject *arg) | |
{ | |
NULLABLE(arg); | |
int overflow = UNINITIALIZED_INT; | |
long value = PyLong_AsLongAndOverflow(arg, &overflow); | |
if (value == -1 && PyErr_Occurred()) { | |
assert(overflow == -1); | |
return NULL; | |
} | |
return Py_BuildValue("li", value, overflow); | |
} |
there is an assertion overflow == -1
when value == -1
. But this is not always true, like if arg
is NULL
.
Reproduce:
from test.support import import_helper
_testlimitedcapi = import_helper.import_module('_testlimitedcapi')
aslonglongandoverflow = _testlimitedcapi.pylong_aslonglongandoverflow
aslonglongandoverflow(None)
Result:
python: ../Modules/_testlimitedcapi/long.c:674: pylong_aslonglongandoverflow: Assertion `overflow == -1' failed.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-130824: Add tests for
NULL
inPyLong_*AndOverflow
functions #130828 - [3.13] gh-130824: Add tests for
NULL
inPyLong_*AndOverflow
functions (GH-130828) #130869 - gh-130824: Clean up test wrappers for PyLong_*AndOverflow functions #130871
- [3.12] gh-130824: Add tests for NULL in PyLong_*AndOverflow functions (GH-130828) #130876
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-C-APItype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error