-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
64/32-bit issue when unpickling random.Random #45014
Comments
If an object containing a random.Random instance is pickled on a 64-bit platform, unpickling the result on a 32-bit platform can cause an OverflowError: File "/usr/local/lib/python2.4/random.py", line 140, in __setstate__ I wasn't able to find any other tickets referring specifically to this. This is in Python 2.4.1 for sure, may be in later versions. |
I've had this same problem with 2.5.1 Pickling random.getstate() on 64bit and then loading it back with The other way around is even worse. It loads but is in a faulty state,
where for example:
>>> random.randrange(1000)
49801980494 This seems like a bug to me. |
Would anybody of you like to work on a patch? |
I've got a patch! The problem was that the state was being cast from a On 32-bit machines this makes large 32-bit longs negative. My patch returns the values with PyLong_FromUnsignedLong() instead of I added code to read states from the old (buggy) version and decypher it This patch is taken from the svn head, but also works on Python 2.5.1 . I haven't tested this patch fully on 64-bit machine yet. I'll let you Cheers, |
Yep, tested it on a 64-bit machine and 2 32-bit machines and back and |
For the record, and to prevent dilution of the count of times this bug has |
Thanks for the patch. Committed as r59295. Because of the version change, the patch cannot be applied to 2.5.x |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: