diff options
author | Zackery Spytz <zspytz@gmail.com> | 2019-06-06 20:39:23 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2019-06-06 20:39:23 (GMT) |
commit | dc2476500d91082f0c907772c83a044bf49af279 (patch) | |
tree | 72075b673111fc2ef0dd389d31e3a2918dd1730c /Modules | |
parent | f6713e84afc5addcfa8477dbdf2c027787f711c0 (diff) | |
download | cpython-dc2476500d91082f0c907772c83a044bf49af279.zip cpython-dc2476500d91082f0c907772c83a044bf49af279.tar.gz cpython-dc2476500d91082f0c907772c83a044bf49af279.tar.bz2 |
bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index f059b4d..c1ae237 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -825,6 +825,26 @@ test_long_as_size_t(PyObject *self, PyObject *Py_UNUSED(ignored)) return Py_None; } +static PyObject * +test_long_as_unsigned_long_long_mask(PyObject *self, + PyObject *Py_UNUSED(ignored)) +{ + unsigned long long res = PyLong_AsUnsignedLongLongMask(NULL); + + if (res != (unsigned long long)-1 || !PyErr_Occurred()) { + return raiseTestError("test_long_as_unsigned_long_long_mask", + "PyLong_AsUnsignedLongLongMask(NULL) didn't " + "complain"); + } + if (!PyErr_ExceptionMatches(PyExc_SystemError)) { + return raiseTestError("test_long_as_unsigned_long_long_mask", + "PyLong_AsUnsignedLongLongMask(NULL) raised " + "something other than SystemError"); + } + PyErr_Clear(); + Py_RETURN_NONE; +} + /* Test the PyLong_AsDouble API. At present this just tests that non-integer arguments are handled correctly. */ @@ -5070,6 +5090,8 @@ static PyMethodDef TestMethods[] = { {"test_long_and_overflow", test_long_and_overflow, METH_NOARGS}, {"test_long_as_double", test_long_as_double, METH_NOARGS}, {"test_long_as_size_t", test_long_as_size_t, METH_NOARGS}, + {"test_long_as_unsigned_long_long_mask", + test_long_as_unsigned_long_long_mask, METH_NOARGS}, {"test_long_numbits", test_long_numbits, METH_NOARGS}, {"test_k_code", test_k_code, METH_NOARGS}, {"test_empty_argparse", test_empty_argparse, METH_NOARGS}, |