Message 55959 - Python tracker (original) (raw)

I've got a patch! The problem was that the state was being cast from a C-type unsigned long to a long.

On 32-bit machines this makes large 32-bit longs negative. On 64-bit machines this preserves the sign of 32-bit values (because they are stored in 64-bit longs).

My patch returns the values with PyLong_FromUnsignedLong() instead of PyInt_FromLong(), therefore there is no casting to long and both 32-bit and 64-bit machines produce the same result.

I added code to read states from the old (buggy) version and decypher it appropriately (from either 32-bit or 64-bit source!). In other words, old pickles can now be opened on either architecture with the new patch.

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 know when I have.

Cheers, -Shawn