Message218385
Perhaps others wouldn't consider this a bug, but it was definitely surprising to me. When switching between optimisation levels -OO (optimise and strip docstrings) and -O (just optimise), you will find the docstrings are still stripped. E.g.
$ ls
hello.py world.py
$ cat hello.py
import world
$ cat world.py
def foo():
'''I'm a docstring'''
pass
import sys
print 'optimization: %d' % sys.flags.optimize
if sys.flags.optimize < 2:
print foo.__doc__
else:
print 'optimisation is enabled; no docstrings'
$ python -OO hello.py
optimization: 2
optimisation is enabled; no docstrings
$ python -O hello.py
optimization: 1
None
$ rm world.pyo
$ python -O hello.py
optimization: 1
I'm a docstring
Is this behaviour intentional? |
|
Date |
User |
Action |
Args |
2014-05-12 23:56:36 | Matthew.Fernandez | set | recipients:
+ Matthew.Fernandez |
2014-05-12 23:56:36 | Matthew.Fernandez | set | messageid: <1399938996.28.0.0918365412077.issue21489@psf.upfronthosting.co.za> |
2014-05-12 23:56:36 | Matthew.Fernandez | link | issue21489 messages |
2014-05-12 23:56:36 | Matthew.Fernandez | create | |
|