-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
old sys.path_hooks importer does not work with Python 3.4.0rc1 #64962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Steps to reproduce: $ cat a.py
import sys class MyFinder:
def __init__(self, path):
if path != "__myfinder__":
raise ImportError()
def find_module(self, fullname, path=None):
return None
sys.path_hooks.append(MyFinder)
sys.path.insert(0, '__myfinder__')
import time
print('OK') $ python3.3 -V
Python 3.3.2+
$ python3.3 a.py
OK
$ python3.4 -V
Python 3.4.0rc1 $ python3.4 a.py
Traceback (most recent call last):
File "a.py", line 14, in <module>
import time
ImportError: spec missing loader On Ubuntu 13.10. Vim's custom importer does not work for it. [vim_dev] Problem with Python 3.4 |
The problem is that the PEP-451 switch accidentally cut out compatibility code for PathEntryFinder.find_module() since Python 3.3 started the transition to find_loader(). Adding a bit of code to http://hg.python.org/cpython/file/8ac9c3754d33/Lib/importlib/_bootstrap.py#l1865 and a test will fix it. |
I should also mention that subclassing importlib.abc.PathEntryFinder solves this coding problem. |
I have a fix, I just need to create a test. |
Fix and test is attached. Can someone review it so I can check it in and get a cherrypick? |
LGTM |
It works fine. Thank you! |
I'll try to commit tonight then and request a cherrypick. |
New changeset 5dec1604322c by Brett Cannon in branch 'default': |
Committed for Larry to cherrypick into 3.4.0. No Misc/NEWS so that Larry doesn't have merge issues and since it will be covered by 3.4.0. |
Cherrypick bug is http://bugs.python.org/issue20789 |
New changeset 149be7000c11 by Brett Cannon in branch '3.4': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: