diff Python/marshal.c @ 17368:bb75d93f6a31 legacy-trunk

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.
author Tim Peters <tim.peters@gmail.com>
date Tue, 10 Apr 2001 05:02:52 +0000
parents 8c41f3861aad
children fe4c1034b480
line wrap: on
line diff
--- a/Python/marshal.c	Tue Apr 10 04:35:28 2001 +0000
+++ b/Python/marshal.c	Tue Apr 10 05:02:52 2001 +0000
@@ -126,7 +126,7 @@
 	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);