Brett Cannon <br...@python.org> added the comment:

Your assessment of what is going on, Andy, is correct; the peephole optimizer 
for bytecode optimizes away the `if __debug__` section of the `if` statement 
for .pyo files.

But that is actually a reasonable thing for the compiler to do as you are not 
supposed to run optimized bytecode with the interpreter not running under -O. 
Running a .pyo file under an interpreter run w/o -O is like compiling for 
64-bit but then running on a 32-bit system; you are not following assumptions 
you told the compiler could be made about the runtime.

So I am closing this as 'wont fix'. Best solution is to simply not run bytecode 
directly and instead execute the source as bytecode should be treated more as 
an optimization than some directly executable file format. But if you must 
execute the bytecode directly, simply make sure you don't mix .pyo/.pyc with an 
improper setting of -O.

----------
nosy: +brett.cannon
resolution:  -> wont fix
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8379>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to