This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年03月24日 17:20 by brett.cannon, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg214702 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2014年03月24日 17:20 | |
Issue #21049 managed to trigger a huge output of "ImportWarning: sys.meta_path is empty" because it managed to trigger an import during interpreter shutdown. The ImportWarning for sys.path_hooks and sys.meta_path were originally added because before importlib took over import it was totally legal to blank out sys.path_hooks and sys.meta_path and have import continue to work. But hopefully by the time Python 3.5 comes out there will be enough knowledge out there to not blindly empty them, making the warning superfluous as well as an annoyance when things go wrong in other respects. |
|||
| msg214703 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2014年03月24日 17:21 | |
I should also say that dropping warnings leaves only a single case of ImportWarning related to empty directory names (in relation to Finder.find_module()). Once that can go away that will eliminate all uses of warnings in importlib and thus won't necessitate importing it in this case. |
|||
| msg214712 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2014年03月24日 19:13 | |
Note that in issue #21409, sys.meta_path isn't "empty", it is actually None. Another possibility is to drop those warnings only when the interpreter is shutting down (it would be easy to add a private API in sys to get that information). |
|||
| msg214715 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2014年03月24日 19:35 | |
It's a simple `if not sys.meta_path` check so it doesn't differentiate. But that's actually a good point about it being None in this case due to the shutdown; if the check changed to `if sys.meta_path is not None and len(sys.meta_path) == 0` then that should skip the shutdown issue while keeping the warning around. Definitely going to be one of those instances where the tests are going to be more troublesome than the fix. =) |
|||
| msg222403 - (view) | Author: Masami HIRATA (msmhrt) | Date: 2014年07月06日 13:14 | |
Hi,
I can reproduce this issue with the following steps.
$ uname -a
Linux ashrose 3.2.0-65-generic #99-Ubuntu SMP Fri Jul 4 21:03:29 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ python3.4 --version
Python 3.4.1
$ touch spam.txt
$ python3.4 -Wa -c "class A: pass; a = open('spam.txt')"
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='spam.txt' mode='r' encoding='UTF-8'>
_frozen_importlib:2150: ImportWarning: sys.meta_path is empty
_frozen_importlib:2150: ImportWarning: sys.meta_path is empty
_frozen_importlib:2150: ImportWarning: sys.meta_path is empty
_frozen_importlib:2150: ImportWarning: sys.meta_path is empty
_frozen_importlib:2150: ImportWarning: sys.meta_path is empty
...
$ python3.4 -Wa -c "a = open('spam.txt')"
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='spam.txt' mode='r' encoding='UTF-8'>
$ python3.4 -Wa -c "class A: pass; open('spam.txt')"
-c:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='spam.txt' mode='r' encoding='UTF-8'>
$
|
|||
| msg229002 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2014年10月10日 14:55 | |
Fixed in https://hg.python.org/cpython/rev/d9f71bc6d897 |
|||
| msg229005 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年10月10日 14:58 | |
New changeset d9f71bc6d897 by Brett Cannon in branch 'default': Issue #21052: Don't raise ImportWarning for sys.meta_path or https://hg.python.org/cpython/rev/d9f71bc6d897 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:00 | admin | set | github: 65251 |
| 2014年10月11日 02:36:12 | berker.peksag | set | stage: test needed -> resolved |
| 2014年10月10日 14:58:08 | python-dev | set | nosy:
+ python-dev messages: + msg229005 |
| 2014年10月10日 14:55:42 | brett.cannon | set | status: open -> closed resolution: fixed messages: + msg229002 |
| 2014年10月09日 18:15:29 | Quentin.Pradet | set | nosy:
+ Quentin.Pradet |
| 2014年10月09日 14:30:53 | brett.cannon | link | issue21049 superseder |
| 2014年09月24日 14:50:38 | brett.cannon | set | assignee: brett.cannon |
| 2014年07月06日 13:14:32 | msmhrt | set | nosy:
+ msmhrt messages: + msg222403 |
| 2014年05月20日 08:23:08 | ikanobori | set | nosy:
+ ikanobori |
| 2014年03月25日 13:13:49 | Arfrever | set | nosy:
+ Arfrever |
| 2014年03月24日 21:39:28 | martin.panter | set | nosy:
+ martin.panter |
| 2014年03月24日 19:35:56 | brett.cannon | set | keywords:
+ easy stage: needs patch -> test needed messages: + msg214715 versions: + Python 3.5 |
| 2014年03月24日 19:13:21 | pitrou | set | nosy:
+ pitrou messages: + msg214712 |
| 2014年03月24日 17:21:54 | brett.cannon | set | messages: + msg214703 |
| 2014年03月24日 17:20:08 | brett.cannon | create | |