mirror of
https://github.com/python/cpython.git
synced 2025-12-07 17:57:56 +00:00
Issue #3236: Return small longs from PyLong_FromString.
This commit is contained in:
parent
2f5799b7b0
commit
029656fb3b
3 changed files with 13 additions and 0 deletions
|
|
@ -95,6 +95,9 @@ class IntTestCases(unittest.TestCase):
|
||||||
self.assertRaises(ValueError, int, "0b", 2)
|
self.assertRaises(ValueError, int, "0b", 2)
|
||||||
self.assertRaises(ValueError, int, "0b", 0)
|
self.assertRaises(ValueError, int, "0b", 0)
|
||||||
|
|
||||||
|
# Bug #3236: Return small longs from PyLong_FromString
|
||||||
|
self.assert_(int("10") is 10)
|
||||||
|
self.assert_(int("-1") is -1)
|
||||||
|
|
||||||
# SF bug 1334662: int(string, base) wrong answers
|
# SF bug 1334662: int(string, base) wrong answers
|
||||||
# Various representations of 2**32 evaluated to 0
|
# Various representations of 2**32 evaluated to 0
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ What's new in Python 3.0b2?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #3236: Return small longs from PyLong_FromString.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1981,6 +1981,14 @@ digit beyond the first.
|
||||||
goto onError;
|
goto onError;
|
||||||
if (pend)
|
if (pend)
|
||||||
*pend = str;
|
*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;
|
return (PyObject *) z;
|
||||||
|
|
||||||
onError:
|
onError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue