[Python-Dev] Changing PYC-Magic

M.-A. Lemburg mal@lemburg.com
Fri, 28 Apr 2000 20:57:18 +0200


I have just looked at the Python/import.c file and the
hard coded PYC magic number...

/* Magic word to reject .pyc files generated by other Python versions */
/* Change for each incompatible change */
/* 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 (20121 | ((long)'\r'<<16) | ((long)'\n'<<24))

A bit outdated, I'd say. With the addition of Unicode, the
PYC files will contain marshalled Unicode objects which are
not readable by older versions. I'd suggest bumping the
magic number to 50428 ;-)

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/