summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-30 04:06:08 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-30 04:06:08 (GMT)
commit029656fb3bc23a2ce03a81fe30bc1b1e5ce5e4cd (patch)
tree9ab92572d81a043d47a30f9be5ed1cef81d922a3 /Objects/longobject.c
parent2f5799b7b07196504186dad98d8528657981ac6a (diff)
downloadcpython-029656fb3bc23a2ce03a81fe30bc1b1e5ce5e4cd.zip
cpython-029656fb3bc23a2ce03a81fe30bc1b1e5ce5e4cd.tar.gz
cpython-029656fb3bc23a2ce03a81fe30bc1b1e5ce5e4cd.tar.bz2
Issue #3236: Return small longs from PyLong_FromString.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c8
1 files changed, 8 insertions, 0 deletions
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 @@ 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: