1919extern time_t PyOS_GetLastModificationTime (char * , FILE * );
2020 /* In getmtime.c */
2121
22- /* Magic word to reject .pyc files generated by other Python versions */
23- /* Change for each incompatible change */
24- /* The value of CR and LF is incorporated so if you ever read or write
22+ /* Magic word to reject .pyc files generated by other Python versions.
23+ It should change for each incompatible change to the bytecode.
24+
25+ The value of CR and LF is incorporated so if you ever read or write
2526 a .pyc file in text mode the magic number will be wrong; also, the
2627 Apple MPW compiler swaps their values, botching string constants.
27- XXX That probably isn't important anymore.
28- */
29- /* XXX Perhaps the magic number should be frozen and a version field
30- added to the .pyc file header? */
31- /* New way to come up with the low 16 bits of the magic number:
32- (YEAR-1995) * 10000 + MONTH * 100 + DAY
33- where MONTH and DAY are 1-based.
34- XXX Whatever the "old way" may have been isn't documented.
35- XXX This scheme breaks in 2002, as (2002-1995)*10000 = 70000 doesn't
36- fit in 16 bits.
37- XXX Later, sometimes 1 gets added to MAGIC in order to record that
38- the Unicode -U option is in use. IMO (Tim's), that's a Bad Idea
39- (quite apart from that the -U option doesn't work so isn't used
40- anyway).
41-
42- XXX MAL, 2002-02-07: I had to modify the MAGIC due to a fix of the
43- UTF-8 encoder (it previously produced invalid UTF-8 for unpaired
44- high surrogates), so I simply bumped the month value to 20 (invalid
45- month) and set the day to 1. This should be recognizable by any
46- algorithm relying on the above scheme. Perhaps we should simply
47- start counting in increments of 10 from now on ?!
48-
49- MWH, 2002-08-03: Removed SET_LINENO. Couldn't be bothered figuring
50- out the MAGIC schemes, so just incremented it by 10.
51-
52- GvR, 2002-08-31: Because MWH changed the bytecode again, moved the
53- magic number *back* to 62011. This should get the snake-farm to
54- throw away its old .pyc files, amongst others.
28+
29+ Apparently, there was a distinction made between even and odd
30+ bytecodes that is related to Unicode. The details aren't clear,
31+ but the magic number has been odd for a long time.
32+
33+ There were a variety of old schemes for setting the magic number.
34+ The current working scheme is to increment the previous value by
35+ 10.
5536
5637 Known values:
5738 Python 1.5: 20121
@@ -66,8 +47,9 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
6647 Python 2.3a0: 62011
6748 Python 2.3a0: 62021
6849 Python 2.3a0: 62011 (!)
50+ Python 2.4a0: 62031
6951*/
70- #define MAGIC (62011 | ((long)'\r'<<16) | ((long)'\n'<<24))
52+ #define MAGIC (62031 | ((long)'\r'<<16) | ((long)'\n'<<24))
7153
7254/* Magic word as global; note that _PyImport_Init() can change the
7355 value of this global to accommodate for alterations of how the
0 commit comments