[issue1538778] pyo's are not overwritten by different optimization levels
Toshio Kuratomi
report at bugs.python.org
Mon Sep 13 18:21:43 CEST 2010
Toshio Kuratomi <a.badger at gmail.com> added the comment:
Here's a usage where this matters. It's a simplification of the bug report that I got that prompted me to open this. Let's say I have the following code:
/usr/lib/python2.7/site-packages/foo.py::
def help():
"""I'm a little docstring, short and sweet"""
print help.__doc__
/usr/bin/bar.py::
#!/usr/bin/python -tt
import sys
import foo
if "--help" in sys.argv:
foo.help()
else:
print "if you type --help, it's me you'll meet"
The system administrator on this box comes along and runs::
$ PYTHONOPTIMIZE=2 bar.py
if you type --help, it's me you'll meet
No problems apparent there but then, the user comes along later and runs::
$ PYTHONOPTIMIZE=1 ./bar.py --help
None
At this point the end user opens a bug against my software telling me that --help is broken which confuses everyone.
Not sure the best way to fix this -- ideas that pop into my head:
These solutions don't lead to a bug report as python does the right thing on its own:
* python reads and write separate pyo files for the different optimization levels (foo.pyo1 foo.pyo2)
* python autodetects whether the cached .pyo was written for the current optimization level and disregards its existence if there's a mismatch (leading to rewriting if the user has permissions, otherwise, recompilation but no writing to disk).
The following solution leads to a bug report but can be diagnosed with just the bug reporter. Note that PYTHONOPTIMIZE= /usr/bin/bar.py is almost as good in this situation:
* python has a commandline switch to disregard current .pyo files.
These solutions lead to a bug report but can be diagnosed with the cooperation of the system administrator in addition to the bug reporter:
* Command line switch that overwrites the .pyo files
* rm -rf *.pyo
----------
nosy: +a.badger
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1538778>
_______________________________________
More information about the Python-bugs-list
mailing list