[Python-checkins] CVS: python/dist/src/Python import.c,2.151,2.152

Tim Peters python-dev@python.org
Thu, 28 Sep 2000 21:03:13 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv25124/python/dist/src/Python

Modified Files:
	import.c 
Log Message:
The 2.0b2 change to write .pyc files in exclusive mode (if possible)
unintentionally caused them to get written in text mode under Windows.
As a result, when .pyc files were later read-- in binary mode --the
magic number was always wrong (note that .pyc magic numbers deliberately
include \r and \n characters, so this was "good" breakage, 100% across
all .pyc files, not random corruption in a subset).  Fixed that.


Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.151
retrieving revision 2.152
diff -C2 -r2.151 -r2.152
*** import.c	2000/09/20 20:31:38	2.151
--- import.c	2000/09/29 04:03:10	2.152
***************
*** 647,651 ****
  	int fd;
  	(void) unlink(filename);
! 	fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC, 0666);
  	if (fd < 0)
  		return NULL;
--- 647,656 ----
  	int fd;
  	(void) unlink(filename);
! 	fd = open(filename, O_EXCL|O_CREAT|O_WRONLY|O_TRUNC
! #ifdef O_BINARY
! 				|O_BINARY   /* necessary for Windows */
! #endif
! 		
! 			, 0666);
  	if (fd < 0)
  		return NULL;