[Python-Dev] PYC Magic (original) (raw)

M.-A. Lemburg mal@lemburg.com
Thu, 07 Feb 2002 12:48:11 +0100


FYI, I've bumped the PYC magic in a non-standard way (the old standard broke on 2002-01-01); please review:

import.c: """ /* 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).

XXX MAL, 2002-02-07: I had to modify the MAGIC due to a fix of the UTF-8 encoder (it previously produced invalid UTF-8 for unpaired high surrogates), so I simply bumped the month value to 20 (invalid month) and set the day to 1. This should be recognizable by any algorithm relying on the above scheme. Perhaps we should simply start counting in increments of 10 from now on ?!

Known values: Python 1.5: 20121 Python 1.5.1: 20121 Python 1.5.2: 20121 Python 2.0: 50823 Python 2.0.1: 50823 Python 2.1: 60202 Python 2.1.1: 60202 Python 2.1.2: 60202 Python 2.2: 60717 Python 2.3a0: 62001 */ #define MAGIC (62001 | ((long)'\r'<<16) | ((long)'\n'<<24)) """

-- Marc-Andre Lemburg CEO eGenix.com Software GmbH


Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/