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 Sworddragon
Recipients Sworddragon
Date 2013-11-09.05:57:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383976647.12.0.628513721742.issue19531@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation says that -OO does remove docstrings so applications should be aware of it. But there is also a case where a valid declared docstring isn't accessible anymore if -O is given. First the testcase:

test1.py:

import test2
def test1():
	"""test1"""
print(test1.__doc__)
print(test2.test2.__doc__)


test2.py:

def test2():
	"""test2"""


A simple check will show the current result:

sworddragon@ubuntu:~/tmp$ python3 -BO test1.py
test1
test2


If -OO is given the docstrings will be removed as expected:

sworddragon@ubuntu:~/tmp$ python3 -OO test1.py
None
None


Now we have also bytecode files saved on the disk without any docstrings. But if we try to use only -O the problem appears:

sworddragon@ubuntu:~/tmp$ python3 -O test1.py
test1
None


Even with only -O given we doesn't get the docstring for the imported module. The problem is that Python allows to load -OO bytecode files if -O bytecode was requested. I think the simplest solution would be to name -OO bytecode-files as .pyoo.
History
Date User Action Args
2013-11-09 05:57:27Sworddragonsetrecipients: + Sworddragon
2013-11-09 05:57:27Sworddragonsetmessageid: <1383976647.12.0.628513721742.issue19531@psf.upfronthosting.co.za>
2013-11-09 05:57:27Sworddragonlinkissue19531 messages
2013-11-09 05:57:26Sworddragoncreate