This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients afriesen, brett.cannon, pitrou, rhettinger
Date 2010-04-12.22:00:03
SpamBayes Score 6.4131214e-08
Marked as misclassified No
Message-id <1271109606.03.0.171426800641.issue8379@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-04-12 22:00:06brett.cannonsetrecipients: + brett.cannon, rhettinger, pitrou, afriesen
2010-04-12 22:00:06brett.cannonsetmessageid: <1271109606.03.0.171426800641.issue8379@psf.upfronthosting.co.za>
2010-04-12 22:00:04brett.cannonlinkissue8379 messages
2010-04-12 22:00:03brett.cannoncreate