[Python-checkins] CVS: python/dist/src/Python import.c,2.191,2.192
Tim Peters
tim_one@users.sourceforge.net
Sat, 17 Nov 2001 20:06:32 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv21711/python/Python
Modified Files:
import.c
Log Message:
Since the MAGIC number scheme is going to break on January 1st, document
what it is more carefully and point out some of the subtleties.
Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.191
retrieving revision 2.192
diff -C2 -d -r2.191 -r2.192
*** import.c 2001/10/30 13:08:39 2.191
--- import.c 2001/11/18 04:06:29 2.192
***************
*** 31,38 ****
/* The value of CR and LF is incorporated so if you ever read or write
a .pyc file in text mode the magic number will be wrong; also, the
! Apple MPW compiler swaps their values, botching string constants */
/* XXX Perhaps the magic number should be frozen and a version field
added to the .pyc file header? */
! /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */
#define MAGIC (60717 | ((long)'\r'<<16) | ((long)'\n'<<24))
--- 31,50 ----
/* The value of CR and LF is incorporated so if you ever read or write
a .pyc file in text mode the magic number will be wrong; also, the
! Apple MPW compiler swaps their values, botching string constants.
! XXX That probably isn't important anymore.
! */
/* XXX Perhaps the magic number should be frozen and a version field
added to the .pyc file header? */
! /* New way to come up with the low 16 bits of the magic number:
! (YEAR-1995) * 10000 + MONTH * 100 + DAY
! where MONTH and DAY are 1-based.
! XXX Whatever the "old way" may have been isn't documented.
! XXX This scheme breaks in 2002, as (2002-1995)*10000 = 70000 doesn't
! fit in 16 bits.
! XXX Later, sometimes 1 gets added to MAGIC in order to record that
! the Unicode -U option is in use. IMO (Tim's), that's a Bad Idea
! (quite apart from that the -U option doesn't work so isn't used
! anyway).
! */
#define MAGIC (60717 | ((long)'\r'<<16) | ((long)'\n'<<24))
***************
*** 64,68 ****
#ifdef MS_WIN32
{".pyw", "r", PY_SOURCE},
! #endif
{".pyc", "rb", PY_COMPILED},
{0, 0}
--- 76,80 ----
#ifdef MS_WIN32
{".pyw", "r", PY_SOURCE},
! #endif
{".pyc", "rb", PY_COMPILED},
{0, 0}
***************
*** 740,744 ****
}
#endif
! cpathname = make_compiled_pathname(pathname, buf,
(size_t)MAXPATHLEN + 1);
if (cpathname != NULL &&
--- 752,756 ----
}
#endif
! cpathname = make_compiled_pathname(pathname, buf,
(size_t)MAXPATHLEN + 1);
if (cpathname != NULL &&