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?
Absolutely not!!!!! .pyc files must remain 100% compatible!!! (Imagine someone doing a .pyc-only distribution for 2.1.3 and finding that it doesn't work for 2.1.4!)
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.
I guess the only way to fix this in 2.1.x is to raise an error -- that's better than the crash that will follow if you try to execute that code.
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.
What do you mean by "can't be written to disk"? Is the disk full? Is there another kind of write error? The magic number is written last, only when the write is successful.
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.
If you're going to change the marshal format anyway, I'd increase all of them to 32 bit ints. After all, I thought the stacksize would never exceed 32K either...
--Guido van Rossum (home page: http://www.python.org/~guido/)