Large functions with size of a bytecode bigger than 65535 bytes may be incorrectly optimized by "optimize_code" in "Python/compile.c". Optimalization happens automaticaly during loading from *.pyc and cannot be disabled. Codes loaded directly from source (*.py) are not optimalized and not affected by this bug. One of task of "optimize_code" is to eliminate "chained" jumps (when one of jumps points directly to unconditional jump). Problems occurs when a first jump opcode points to JUMP_FORWARD, which target is after 64K boundary. This target adress is copied as absolute address of the first jump modulo 2**16. This bug can lead to different symptoms during execution of a code. You can get an "unknown opcode" error, but sometimes results can be unpredicable. This problem appears in Python 2.3 (tested) and possibly in 2.4 (alfa). Attached scripts generates large functions a writes disassebles before and after optimalization. You will find, that some adresses after optimalization are bad.
Logged In: YES user_id=31435 Raised priority and assigned to Raymond. I haven't verified the claim, but it sounds more plausible than not, and is a critical bug if so.