Message116324
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 |
|
| Date |
User |
Action |
Args |
| 2010-09-13 16:21:43 | a.badger | set | recipients:
+ a.badger, loewis, barry, brett.cannon, ajaksu2, abadger1999, eric.araujo |
| 2010-09-13 16:21:43 | a.badger | set | messageid: <1284394903.63.0.402957992099.issue1538778@psf.upfronthosting.co.za> |
| 2010-09-13 16:21:42 | a.badger | link | issue1538778 messages |
| 2010-09-13 16:21:41 | a.badger | create | |
|