summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2012-12-28 07:42:11 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2012-12-28 07:42:11 (GMT)
commit0b386d524765d875fd5f7b6150219e5e5cd69abf (patch)
tree685ff50538e96318e1f9384448e2b5a5aedfb302 /Objects/longobject.c
parent1e4bd53a34a46e44a5e88a6ecc5ea4f102b94b6f (diff)
downloadcpython-0b386d524765d875fd5f7b6150219e5e5cd69abf.zip
cpython-0b386d524765d875fd5f7b6150219e5e5cd69abf.tar.gz
cpython-0b386d524765d875fd5f7b6150219e5e5cd69abf.tar.bz2
Issue #16761: Raise TypeError when int() called with base argument only.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 3a675c4..51da329 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4130,8 +4130,14 @@ 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);
@@ -4140,7 +4146,7 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
if (overflow || (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;
}