mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #16761: Raise TypeError when int() called with base argument only.
This commit is contained in:
commit
c819b077bb
3 changed files with 14 additions and 13 deletions
|
@ -4255,13 +4255,19 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:int", kwlist,
|
||||
&x, &obase))
|
||||
return NULL;
|
||||
if (x == NULL)
|
||||
if (x == NULL) {
|
||||
if (obase != NULL) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"int() missing string argument");
|
||||
return NULL;
|
||||
}
|
||||
return PyLong_FromLong(0L);
|
||||
}
|
||||
if (obase == NULL)
|
||||
return PyNumber_Long(x);
|
||||
if (!PyLong_Check(obase)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"int() arg 2 must be an integer.");
|
||||
"int() base must be an integer.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -4270,7 +4276,7 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
if ((base != 0 && base < 2) || base > 36) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"int() arg 2 must be >= 2 and <= 36");
|
||||
"int() base must be >= 2 and <= 36");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue