Message202462
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. |
|
Date |
User |
Action |
Args |
2013-11-09 05:57:27 | Sworddragon | set | recipients:
+ Sworddragon |
2013-11-09 05:57:27 | Sworddragon | set | messageid: <1383976647.12.0.628513721742.issue19531@psf.upfronthosting.co.za> |
2013-11-09 05:57:27 | Sworddragon | link | issue19531 messages |
2013-11-09 05:57:26 | Sworddragon | create | |
|