Test for issue16772 and redoes the previous fix to accept __index__-aware
objects as the base by using PyNumber_AsSsize_t similar to round().
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 @@
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 @@
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;