[Python-Dev] PYC Magic

Neal Norwitz neal@metaslash.com
Sat, 01 Jun 2002 09:20:04 -0400


I recently posted a patch to fix a bug:  http://python.org/sf/561858.
The patch requires changing .pyc magic.  Since this bug goes back
to 2.1, what is the process for changing .pyc magic in bugfix releases?
ie, is it allowed?

In this case the co_stacksize > 32767 and only a short is written 
to disk.  This could be doubled to 65536 (probably should be) 
without changing the magic.  But even that isn't sufficient 
to solve this problem.

It also brings up a related problem.  If the PyCodeObject 
can't be written to disk, should a .pyc be created at all?  
The code will run fine the first time, but when imported 
the second time it will fail.

The other 16 bit values stored are:  co_argcount, co_nlocals, co_flags.
At least argcount & nlocals aren't too likely to exceed 32k, but
co_flags could, which would be silently ignored now.

Neal