diff options
author | Zackery Spytz <zspytz@gmail.com> | 2019-06-07 09:41:10 -0600 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2019-06-07 17:41:10 +0200 |
commit | e36ed475ea429f7cc80a4d65f80b44686a74b246 (patch) | |
tree | 10fde905cce142de868716059b0a1377618a5324 /Modules | |
parent | 4ea9dbda4ad823875ed79a25062a7f5415d91b22 (diff) | |
download | cpython-git-e36ed475ea429f7cc80a4d65f80b44686a74b246.tar.gz |
[3.7] bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860) (GH-13896)
(cherry picked from commit dc2476500d91082f0c907772c83a044bf49af279)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
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 b864f9270e..64b7b69049 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -816,6 +816,26 @@ test_long_as_size_t(PyObject *self) 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. */ @@ -4663,6 +4683,8 @@ static PyMethodDef TestMethods[] = { METH_NOARGS}, {"test_long_as_double", (PyCFunction)test_long_as_double,METH_NOARGS}, {"test_long_as_size_t", (PyCFunction)test_long_as_size_t,METH_NOARGS}, + {"test_long_as_unsigned_long_long_mask", + (PyCFunction)test_long_as_unsigned_long_long_mask, METH_NOARGS}, {"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS}, {"test_k_code", (PyCFunction)test_k_code, METH_NOARGS}, {"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS}, |