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 Matthew.Fernandez
Recipients Matthew.Fernandez
Date 2014-05-12.23:56:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1399938996.28.0.0918365412077.issue21489@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2014-05-12 23:56:36Matthew.Fernandezsetrecipients: + Matthew.Fernandez
2014-05-12 23:56:36Matthew.Fernandezsetmessageid: <1399938996.28.0.0918365412077.issue21489@psf.upfronthosting.co.za>
2014-05-12 23:56:36Matthew.Fernandezlinkissue21489 messages
2014-05-12 23:56:36Matthew.Fernandezcreate