summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2012-12-26 06:38:32 (GMT)
committerGregory P. Smith <greg@krypto.org>2012-12-26 06:38:32 (GMT)
commita689e524e7465b5facc07f493adfa7eda6b918d4 (patch)
tree9d128bee57985c61bbae5bbbd5a7b153678e3271 /Objects/longobject.c
parent83a2aa70af52eaddaaaff13167d8b1f61567d481 (diff)
downloadcpython-a689e524e7465b5facc07f493adfa7eda6b918d4.zip
cpython-a689e524e7465b5facc07f493adfa7eda6b918d4.tar.gz
cpython-a689e524e7465b5facc07f493adfa7eda6b918d4.tar.bz2
Test for issue16772 and redoes the previous fix to accept __index__-aware
objects as the base by using PyNumber_AsSsize_t similar to round().
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index e4d4df4..cea2f73 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4247,8 +4247,7 @@ static PyObject *
long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *obase = NULL, *x = NULL;
- long base;
- int overflow;
+ Py_ssize_t base;
static char *kwlist[] = {"x", "base", 0};
if (type != &PyLong_Type)
@@ -4266,10 +4265,10 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
- base = PyLong_AsLongAndOverflow(obase, &overflow);
+ base = PyNumber_AsSsize_t(obase, NULL);
if (base == -1 && PyErr_Occurred())
return NULL;
- if (overflow || (base != 0 && base < 2) || base > 36) {
+ if ((base != 0 && base < 2) || base > 36) {
PyErr_SetString(PyExc_ValueError,
"int() arg 2 must be >= 2 and <= 36");
return NULL;