[issue21049] Warning at interpreter exit triggers flood of “ImportWarning: sys.meta_path is empty”

Martin Panter report at bugs.python.org
Thu Oct 9 03:53:58 CEST 2014


Martin Panter added the comment:

Quentin, do you think this should be reopened?

Brett Cannon, I wonder if the only reason you closed this bug is because you thought the scenario to trigger it is very unlikely. Considering it affected someone else, and that there are other real-world triggers in addition to Py Socks, would it be okay to reopen it? I could try to make a patch or some concrete suggestions when I have a chance, if that helps change your mind :)

Perhaps a regression test could be based on this experiment:

>>> import sys, warnings
>>> sys.meta_path = None
>>> sys.modules.pop("linecache", None)
<module 'linecache' from '/usr/lib/python3.4/linecache.py'>
>>> warnings.warn("boom")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/warnings.py", line 15, in showwarning
    file.write(formatwarning(message, category, filename, lineno, line))
  File "/usr/lib/python3.4/warnings.py", line 21, in formatwarning
    import linecache
  File "/home/proj/python/lib/misc.py", line 41, in __call__
    return self.__wrapped__(name, globals, locals, fromlist, level)
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 2150, in _find_spec
  File "/usr/lib/python3.4/warnings.py", line 15, in showwarning
    file.write(formatwarning(message, category, filename, lineno, line))
. . .
  File "<frozen importlib._bootstrap>", line 2236, in _find_and_load
RuntimeError: maximum recursion depth exceeded while calling a Python object

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21049>
_______________________________________


More information about the Python-bugs-list mailing list