summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2012-12-28 07:31:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2012-12-28 07:31:59 (GMT)
commitcf095f8e0f0ed1111995a5b8a8a5ebdb189683f2 (patch)
tree03937818d78df6c7bd5f3cc8fdcbabcf0c302f2b /Objects
parent3684c79e00ad923fa2400458c1a02d6afa3c5ce8 (diff)
downloadcpython-cf095f8e0f0ed1111995a5b8a8a5ebdb189683f2.zip
cpython-cf095f8e0f0ed1111995a5b8a8a5ebdb189683f2.tar.gz
cpython-cf095f8e0f0ed1111995a5b8a8a5ebdb189683f2.tar.bz2
Issue #16761: Raise TypeError when int() or long() called with base argument only.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/intobject.c8
-rw-r--r--Objects/longobject.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 74955ad..1ae8006 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -1059,8 +1059,14 @@ int_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:int", kwlist,
&x, &base))
return NULL;
- if (x == NULL)
+ if (x == NULL) {
+ if (base != -909) {
+ PyErr_SetString(PyExc_TypeError,
+ "int() missing string argument");
+ return NULL;
+ }
return PyInt_FromLong(0L);
+ }
if (base == -909)
return PyNumber_Int(x);
if (PyString_Check(x)) {
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 9296ad4..5a6338f 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -3987,8 +3987,14 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:long", kwlist,
&x, &base))
return NULL;
- if (x == NULL)
+ if (x == NULL) {
+ if (base != -909) {
+ PyErr_SetString(PyExc_TypeError,
+ "long() missing string argument");
+ return NULL;
+ }
return PyLong_FromLong(0L);
+ }
if (base == -909)
return PyNumber_Long(x);
else if (PyString_Check(x)) {