diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-03-09 18:03:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 18:03:38 (GMT) |
commit | e5ccc94bbb153431698b2391df625e8d47a93276 (patch) | |
tree | 82c6656cd615dc3ae3311d42d2ef580fa1d8e4d8 /Modules | |
parent | 413f01352a8268fb62bb47bde965462d7b82a06a (diff) | |
download | cpython-e5ccc94bbb153431698b2391df625e8d47a93276.zip cpython-e5ccc94bbb153431698b2391df625e8d47a93276.tar.gz cpython-e5ccc94bbb153431698b2391df625e8d47a93276.tar.bz2 |
bpo-38643: Raise SystemError instead of crashing when PyNumber_ToBase is called with invalid base. (GH-18863)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 23a27e3..2b871b8 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5259,6 +5259,19 @@ meth_fastcall_keywords(PyObject* self, PyObject* const* args, } +static PyObject* +pynumber_tobase(PyObject *module, PyObject *args) +{ + PyObject *obj; + int base; + if (!PyArg_ParseTuple(args, "Oi:pynumber_tobase", + &obj, &base)) { + return NULL; + } + return PyNumber_ToBase(obj, base); +} + + static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *); static PyMethodDef TestMethods[] = { @@ -5519,6 +5532,7 @@ static PyMethodDef TestMethods[] = { {"meth_noargs", meth_noargs, METH_NOARGS}, {"meth_fastcall", (PyCFunction)(void(*)(void))meth_fastcall, METH_FASTCALL}, {"meth_fastcall_keywords", (PyCFunction)(void(*)(void))meth_fastcall_keywords, METH_FASTCALL|METH_KEYWORDS}, + {"pynumber_tobase", pynumber_tobase, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; |