[Python-3000-checkins] r64596 - in python/branches/py3k: Lib/test/test_int.py Misc/NEWS Objects/longobject.c
Guido van Rossum
guido at python.org
Mon Jun 30 17:26:38 CEST 2008
On Sun, Jun 29, 2008 at 9:06 PM, martin.v.loewis
<python-3000-checkins at python.org> wrote:
> Author: martin.v.loewis
> Date: Mon Jun 30 06:06:08 2008
> New Revision: 64596
>
> Log:
> Issue #3236: Return small longs from PyLong_FromString.
>
>
> Modified:
> python/branches/py3k/Lib/test/test_int.py
> python/branches/py3k/Misc/NEWS
> python/branches/py3k/Objects/longobject.c
>
> Modified: python/branches/py3k/Lib/test/test_int.py
> ==============================================================================
> --- python/branches/py3k/Lib/test/test_int.py (original)
> +++ python/branches/py3k/Lib/test/test_int.py Mon Jun 30 06:06:08 2008
> @@ -95,6 +95,9 @@
> self.assertRaises(ValueError, int, "0b", 2)
> 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)
This is the kind of test that other implementations may not wish to
comply with. Do we have a mechanism yet for flagging tests as specific
to CPython?
> # SF bug 1334662: int(string, base) wrong answers
> # Various representations of 2**32 evaluated to 0
>
> Modified: python/branches/py3k/Misc/NEWS
> ==============================================================================
> --- python/branches/py3k/Misc/NEWS (original)
> +++ python/branches/py3k/Misc/NEWS Mon Jun 30 06:06:08 2008
> @@ -12,6 +12,8 @@
> Core and Builtins
> -----------------
>
> +- Issue #3236: Return small longs from PyLong_FromString.
> +
> Library
> -------
>
>
> Modified: python/branches/py3k/Objects/longobject.c
> ==============================================================================
> --- python/branches/py3k/Objects/longobject.c (original)
> +++ python/branches/py3k/Objects/longobject.c Mon Jun 30 06:06:08 2008
> @@ -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:
> _______________________________________________
> Python-3000-checkins mailing list
> Python-3000-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000-checkins
mailing list