New submission from Sworddragon:
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.
----------
components: Interpreter Core
messages: 202462
nosy: Sworddragon
priority: normal
severity: normal
status: open
title: Loading -OO bytecode files if -O was requested can lead to problems
type: enhancement
versions: Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19531>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com