Issue #3236: Return small longs from PyLong_FromString.

This commit is contained in:
Martin v. Löwis 2008-06-30 04:06:08 +00:00
parent 2f5799b7b0
commit 029656fb3b
3 changed files with 13 additions and 0 deletions

View file

@ -1981,6 +1981,14 @@ digit beyond the first.
goto onError;
if (pend)
*pend = str;
long_normalize(z);
if (ABS(Py_SIZE(z)) <= 1) {
long res = MEDIUM_VALUE(z);
if (-NSMALLPOSINTS <= res && res <= NSMALLPOSINTS) {
Py_DECREF(z);
return PyLong_FromLong(res);
}
}
return (PyObject *) z;
onError: