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

2014-10-10 Thread Brett Cannon

Brett Cannon added the comment:

This has now been fixed in https://hg.python.org/cpython/rev/d9f71bc6d897 . 
Thanks to everyone who helped with the bug report!

--
versions: +Python 3.5 -Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21049
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-10-09 Thread Quentin Pradet

Quentin Pradet added the comment:

Martin, yes, I'd be glad to see a fix if it's not too complicated.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21049
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-10-09 Thread Brett Cannon

Brett Cannon added the comment:

I'm already planning to look into this problem in issue #21052 so feel free to 
follow over there.

--
superseder:  - Consider dropping ImportWarning for empty sys.path_hooks and 
sys.meta_path

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21049
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-10-08 Thread Martin Panter

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 , 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 rep...@bugs.python.org
http://bugs.python.org/issue21049
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-09-24 Thread Quentin Pradet

Quentin Pradet added the comment:

I've also been affected by this when testing integration with a third-party 
library (NLTK). NLTK does need to be fixed, but the ResourceWarning already say 
so.

The new one-liner doesn't seem contrived to me.

--
nosy: +Quentin.Pradet

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21049
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-09-17 Thread Martin Panter

Martin Panter added the comment:

My original demonstration was distilled from a real world case. I get this 
issue with other real world cases too, so I am expanding the title to reflect 
what I think is going on. This problem seems to be caused by a ResourceWarning 
triggered from a garbage cycle being freed just before Python exits. The flood 
of ImportWarning lines makes it annoying to scroll up to see what other 
ResourceWarning messages, exceptions, etc you are missing out on.

Much simpler one-liner demonstration adapted from Message 222403 (because class 
definitions create garbage cycles in my experience):

python3 -Wall -c 'class C: a = open(/dev/null)'

The best workaround is probably to use “python -Wdefault” rather than “python 
-Wall”. Then you only get one ImportWarning line.

I suspect the problem might be caused by a recursive loop between emitting a 
warning and importing something, as Antoine hinted. Calling 
sys.setrecursionlimit(30) reduces the flood to 5 lines. Unfortunately my 
modifications to “importlib/_bootstrap.py” and “warnings.py” on my OS are not 
having any effect, otherwise I might try to make a patch.

Perhaps if it is not appropriate for the ImportWarning to be removed, could the 
code printing out the warning be changed to avoid triggering it in the first 
place?

--
title: Flood of “ImportWarning: sys.meta_path is empty” after exception with 
socket subclass - Warning at interpreter exit triggers flood of 
“ImportWarning: sys.meta_path is empty”

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21049
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com