[Python-Dev] #12982: Should -O be required to *read* .pyo files?

R. David Murray rdmurray at bitdance.com
Thu Jun 14 04:47:45 CEST 2012


On Thu, 14 Jun 2012 11:48:08 +1000, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Thu, Jun 14, 2012 at 6:06 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> > On 6/13/2012 2:46 PM, Antoine Pitrou wrote:
> >
> >> Not only docstrings, but also asserts. I think running a pyo without -O
> >> would be a bug.
> >
> > That cat is already out of the bag ;-)
> > People are doing that now by renaming x.pyo to x.pyc.
> > Brett claims that it is also easy to do in 3.3 with a custom importer.
> 
> Right, but by resorting to either of those approaches, people are
> clearly doing something that isn't formally supported by the core.
> Yes, you can do it, and most of the time it will work out OK, but any
> weird glitches that result are officially *not our problem*.
> 
> The main reason this matters is that the "__debug__" flag is
> *supposed* to be process global - if you check it in one place, the

OK, the above are the two concrete reasons I have heard in this thread
for continuing the current behavior:

    1) we do not wish to support running from .pyo files without -O
       being on, even if it currently happens to work

    2) the __debug__ setting is supposed to be process-global

Both of these are good reasons.  IMO the issue should be closed with a
documentation fix, which could optionally include either or both of the
above motivations.

--David


More information about the Python-Dev mailing list