mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
test_pickle works on sizeof(long)==8 boxes again.
pickle.py The code implicitly assumed that all ints fit in 4 bytes, causing all sorts of mischief (from nonsense results to corrupted pickles). Repaired that. marshal.c The int marshaling code assumed that right shifts of signed longs sign-extend. Repaired that.
This commit is contained in:
parent
d8ae7c2999
commit
44714007e8
2 changed files with 19 additions and 12 deletions
|
@ -126,7 +126,7 @@ w_object(PyObject *v, WFILE *p)
|
|||
else if (PyInt_Check(v)) {
|
||||
long x = PyInt_AS_LONG((PyIntObject *)v);
|
||||
#if SIZEOF_LONG > 4
|
||||
long y = x>>31;
|
||||
long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
|
||||
if (y && y != -1) {
|
||||
w_byte(TYPE_INT64, p);
|
||||
w_long64(x, p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue