[Python-checkins] python/dist/src/Python import.c,2.205,2.206 marshal.c,1.71,1.72

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Thu, 13 Jun 2002 18:07:42 -0700


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

Modified Files:
	import.c marshal.c 
Log Message:
Fix SF bug # 561858 Assertion with very long lists

Write 4 bytes for co_stacksize, etc. to prevent writing out
bad .pyc files which can cause a crash when read back in.


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.205
retrieving revision 2.206
diff -C2 -d -r2.205 -r2.206
*** import.c	13 Jun 2002 20:33:02 -0000	2.205
--- import.c	14 Jun 2002 01:07:39 -0000	2.206
***************
*** 60,66 ****
         Python 2.1.2: 60202
         Python 2.2:   60717
!        Python 2.3a0: 62001
  */
! #define MAGIC (62001 | ((long)'\r'<<16) | ((long)'\n'<<24))
  
  /* Magic word as global; note that _PyImport_Init() can change the
--- 60,66 ----
         Python 2.1.2: 60202
         Python 2.2:   60717
!        Python 2.3a0: 62011
  */
! #define MAGIC (62011 | ((long)'\r'<<16) | ((long)'\n'<<24))
  
  /* Magic word as global; note that _PyImport_Init() can change the

Index: marshal.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** marshal.c	3 Apr 2002 22:41:51 -0000	1.71
--- marshal.c	14 Jun 2002 01:07:39 -0000	1.72
***************
*** 242,249 ****
  		PyCodeObject *co = (PyCodeObject *)v;
  		w_byte(TYPE_CODE, p);
! 		w_short(co->co_argcount, p);
! 		w_short(co->co_nlocals, p);
! 		w_short(co->co_stacksize, p);
! 		w_short(co->co_flags, p);
  		w_object(co->co_code, p);
  		w_object(co->co_consts, p);
--- 242,249 ----
  		PyCodeObject *co = (PyCodeObject *)v;
  		w_byte(TYPE_CODE, p);
! 		w_long(co->co_argcount, p);
! 		w_long(co->co_nlocals, p);
! 		w_long(co->co_stacksize, p);
! 		w_long(co->co_flags, p);
  		w_object(co->co_code, p);
  		w_object(co->co_consts, p);
***************
*** 254,258 ****
  		w_object(co->co_filename, p);
  		w_object(co->co_name, p);
! 		w_short(co->co_firstlineno, p);
  		w_object(co->co_lnotab, p);
  	}
--- 254,258 ----
  		w_object(co->co_filename, p);
  		w_object(co->co_name, p);
! 		w_long(co->co_firstlineno, p);
  		w_object(co->co_lnotab, p);
  	}
***************
*** 589,596 ****
  		}
  		else {
! 			int argcount = r_short(p);
! 			int nlocals = r_short(p);
! 			int stacksize = r_short(p);
! 			int flags = r_short(p);
  			PyObject *code = NULL;
  			PyObject *consts = NULL;
--- 589,596 ----
  		}
  		else {
! 			int argcount = r_long(p);
! 			int nlocals = r_long(p);
! 			int stacksize = r_long(p);
! 			int flags = r_long(p);
  			PyObject *code = NULL;
  			PyObject *consts = NULL;
***************
*** 613,617 ****
  			if (filename) name = r_object(p);
  			if (name) {
! 				firstlineno = r_short(p);
  				lnotab = r_object(p);
  			}
--- 613,617 ----
  			if (filename) name = r_object(p);
  			if (name) {
! 				firstlineno = r_long(p);
  				lnotab = r_object(p);
  			}