commit | 029656fb3bc23a2ce03a81fe30bc1b1e5ce5e4cd | [log] [tgz] |
---|---|---|
author | Martin v. Löwis <martin@v.loewis.de> | Mon Jun 30 04:06:08 2008 +0000 |
committer | Martin v. Löwis <martin@v.loewis.de> | Mon Jun 30 04:06:08 2008 +0000 |
tree | 9ab92572d81a043d47a30f9be5ed1cef81d922a3 | |
parent | 2f5799b7b07196504186dad98d8528657981ac6a [diff] [blame] |
Issue #3236: Return small longs from PyLong_FromString.
diff --git a/Objects/longobject.c b/Objects/longobject.c index d1c27e6..2c684cb 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c
@@ -1981,6 +1981,14 @@ 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: