New submission from Matthew Fernandez: 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? ---------- messages: 218385 nosy: Matthew.Fernandez priority: normal severity: normal status: open title: Switching from -OO to -O still uses cached bytecode versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21489> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com