[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Changes by Mark Dickinson : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Fixed. Thanks Brecht for the report (and Antoine for diagnosing the problem). -- resolution: -> fixed ___ Python tracker ___

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Roundup Robot
Roundup Robot added the comment: New changeset cdcc6b489862 by Mark Dickinson in branch '3.2': Issue #14630: Fix an incorrect access of ob_digit[0] for a zero instance of an int subclass. http://hg.python.org/cpython/rev/cdcc6b489862 New changeset c7b0f711dc15 by Mark Dickinson in branch 'defa

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Stefan Krah
Stefan Krah added the comment: The patch looks good to me. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: The patch works fine here, and the test exercises the issue correctly. -- ___ Python tracker ___ __

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Changes by Mark Dickinson : -- stage: needs patch -> commit review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscrib

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Also, Python 2.7 looks safe here. -- versions: -Python 2.7 ___ Python tracker ___ ___ Python-bugs-

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Changes by Mark Dickinson : -- keywords: +patch Added file: http://bugs.python.org/file25291/issue14630.patch ___ Python tracker ___ _

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Here's the patch. I searched through the rest of Objects/longobject.c for other occurrences of [0], and found nothing else that looked suspicious, so I'm reasonably confident that this was an isolated case. -- ___

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson 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 @

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- components: +Interpreter Core -None stage: -> needs patch ___ Python tracker ___ ___ Python-bugs-list

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: The fix for _PyLong_Copy is the following: diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -156,7 +156,7 @@ PyObject * if (i < 0) i = -(i); if (i < 2) { -sdigit ival =

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Self-contained example that fails for me on 32-bit OS X. class Integer(int): def __new__(cls, value, base=10, indirect=False): try: obj = int.__new__(cls, value, base) except TypeError: obj = int.__new__(cls, value

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Changes by Mark Dickinson : -- assignee: -> mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: > _PyLong_Copy does. Grr. So it does. That at least should be fixed, but I agree that it would be good to have the added protection of ensuring that we always allocate space for at least one limb. We should also check whether 2.7 is susceptible. -

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: > If we're accessing ob_digit[0] when Py_SIZE(x) == 0, that sounds like a > bug to me. _PyLong_Copy does. It's ok as long as the object is int(0), because it's part of the small ints and its allocated size is one digit. The following hack seems to fix the is

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: If we're accessing ob_digit[0] when Py_SIZE(x) == 0, that sounds like a bug to me. -- ___ Python tracker ___ _

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: Reproduced under 32-bit Linux. The problem seems to be that Py_SIZE(x) == 0 when x is Integer(0), but ob_digit[0] is still supposed to be significant. There's probably some overwriting with the trailing attributes. By forcing Py_SIZE(x) == 1, the bug disappear

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: I can reproduce this on a 32-bit OS X build of the default branch, so it doesn't seem to be Windows specific (though it may be 32-bit specific). Brecht, if you can find a way to reduce the size of your example at all that would be really helpful. --

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue14630] non-deterministic behavior of int subclass

2012-04-20 Thread Brecht Machiels
New submission from Brecht Machiels : I have subclassed int to add an extra attribute: class Integer(int): def __new__(cls, value, base=10, indirect=False): try: obj = int.__new__(cls, value, base) except TypeError: obj = int.__new__(cls, value)