mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-38643: Raise SystemError instead of crashing when PyNumber_ToBase is called with invalid base. (GH-18863)
This commit is contained in:
parent
413f01352a
commit
e5ccc94bbb
4 changed files with 36 additions and 9 deletions
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue