]> granicus.if.org Git - python/commitdiff
Fixes issue #16772: int() constructor second argument (base) must be an int.
authorGregory P. Smith <greg@krypto.org>
Tue, 25 Dec 2012 21:05:31 +0000 (13:05 -0800)
committerGregory P. Smith <greg@krypto.org>
Tue, 25 Dec 2012 21:05:31 +0000 (13:05 -0800)
Consistent with the behavior in Python 2.

Misc/NEWS
Objects/longobject.c

index 8da0d7433a4baca5aca85f771774fad21600a356..b85fd43175ac1100052b72105d98fc0c259339e7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
 Core and Builtins
 -----------------
 
+- Issue #16772: The int() constructor's second argument (base) no longer
+  accepts non integer values.  Consistent with the behavior in Python 2.
+
 - Issue #15422: Get rid of PyCFunction_New macro. Use PyCFunction_NewEx
   function (PyCFunction_New func is still present for backward compatibility).
 
index 4024491f133736ab9a0993941d7f3af982bfed84..e4d4df46f3a2885a4f96a287d3d4da7a36e1917d 100644 (file)
@@ -4260,6 +4260,11 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
         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.");
+        return NULL;
+    }
 
     base = PyLong_AsLongAndOverflow(obase, &overflow);
     if (base == -1 && PyErr_Occurred())