[issue14630] non-deterministic behavior of int subclass

Mark Dickinson report at bugs.python.org
Fri Apr 20 14:18:37 CEST 2012


Mark Dickinson <dickinsm at gmail.com> added the comment:

Using MEDIUM_VALUE also works.

I'll cook up a patch tonight, after work.


diff -r 6762b943ee59 Objects/longobject.c
--- a/Objects/longobject.c	Tue Apr 17 21:42:07 2012 -0400
+++ b/Objects/longobject.c	Fri Apr 20 13:18:01 2012 +0100
@@ -156,9 +156,7 @@
     if (i < 0)
         i = -(i);
     if (i < 2) {
-        sdigit ival = src->ob_digit[0];
-        if (Py_SIZE(src) < 0)
-            ival = -ival;
+        sdigit ival = MEDIUM_VALUE(src);
         CHECK_SMALL_INT(ival);
     }
     result = _PyLong_New(i);

----------
assignee:  -> mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14630>
_______________________________________


More information about the Python-bugs-list mailing list