[Python-checkins] CVS: python/dist/src/Python marshal.c,1.61,1.62

Tim Peters tim_one@users.sourceforge.net
Mon, 09 Apr 2001 22:02:54 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv1600/python/dist/src/Python

Modified Files:
	marshal.c 
Log Message:
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.


Index: marshal.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -r1.61 -r1.62
*** marshal.c	2001/01/28 00:27:39	1.61
--- marshal.c	2001/04/10 05:02:52	1.62
***************
*** 127,131 ****
  		long x = PyInt_AS_LONG((PyIntObject *)v);
  #if SIZEOF_LONG > 4
! 		long y = x>>31;
  		if (y && y != -1) {
  			w_byte(TYPE_INT64, p);
--- 127,131 ----
  		long x = PyInt_AS_LONG((PyIntObject *)v);
  #if SIZEOF_LONG > 4
! 		long y = Py_ARITHMETIC_RIGHT_SHIFT(long, x, 31);
  		if (y && y != -1) {
  			w_byte(TYPE_INT64, p);