[issue31676] Strange failure in test_cgitb

STINNER Victor report at bugs.python.org
Tue Oct 3 10:31:32 EDT 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

The problem is that imp.load_source() modifies __file__ of the __main__ module.

Example of a file x.py:
---
import imp
import sys
print(sys.modules[__name__])
try:
    imp.load_source(__name__, __file__ + "\0")
except:
    pass
print(sys.modules[__name__])
---

Output:
---
<module '__main__' from 'x.py'>
<module '__main__' from 'x.py\x00'>
---

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31676>
_______________________________________


More information about the Python-bugs-list mailing list