diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2012-12-28 08:09:54 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2012-12-28 08:09:54 (GMT) |
commit | c819b077bb9125db303651a383fb03e68c822084 (patch) | |
tree | f037dec4edc5e92224eaf1a6b6ec5c06eff72e75 /Objects/longobject.c | |
parent | d6c18dcd20ec4cc94c2c99aff165780d16a6f13b (diff) | |
parent | 00e284311565c2caeadd10faa75cbe261b71bdaf (diff) | |
download | cpython-c819b077bb9125db303651a383fb03e68c822084.zip cpython-c819b077bb9125db303651a383fb03e68c822084.tar.gz cpython-c819b077bb9125db303651a383fb03e68c822084.tar.bz2 |
Issue #16761: Raise TypeError when int() called with base argument only.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 49e9d5d..5a50f24 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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; } |