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.

classification
Title: old sys.path_hooks importer does not work with Python 3.4.0rc1
Type: Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: Arfrever, brett.cannon, donmez, eric.snow, larry, matejcik, python-dev, ynkdir, yselivanov
Priority: release blocker Keywords: patch

Created on 2014-02-25 03:36 by ynkdir, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_20763.diff brett.cannon, 2014-02-26 01:02 review
Messages (12)
msg212158 - (view) Author: Yukihiro Nakadaira (ynkdir) Date: 2014-02-25 03:36
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.
python3.3 is ubuntu's package.
python3.4.0rc1 is built by myself.

Vim's custom importer does not work for it.

[vim_dev] Problem with Python 3.4
https://groups.google.com/d/msg/vim_dev/RfuOG7_Jabs/h3YzLTsRgv0J
msg212189 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-25 16:51
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.
msg212190 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-25 16:54
I should also mention that subclassing importlib.abc.PathEntryFinder solves this coding problem.
msg212229 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-25 23:56
I have a fix, I just need to create a test.
msg212233 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-26 01:02
Fix and test is attached. Can someone review it so I can check it in and get a cherrypick?
msg212234 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-02-26 02:10
LGTM
msg212254 - (view) Author: Yukihiro Nakadaira (ynkdir) Date: 2014-02-26 13:45
It works fine.  Thank you!
msg212261 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-26 15:20
I'll try to commit tonight then and request a cherrypick.
msg212325 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-02-26 23:26
New changeset 5dec1604322c by Brett Cannon in branch 'default':
Issue #20763: Fix importlib.machinery.PathFinder to support
http://hg.python.org/cpython/rev/5dec1604322c
msg212327 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-26 23:29
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.
msg212328 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-02-26 23:29
Cherrypick bug is http://bugs.python.org/issue20789
msg213832 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-17 06:31
New changeset 149be7000c11 by Brett Cannon in branch '3.4':
Issue #20763: Fix importlib.machinery.PathFinder to support
http://hg.python.org/cpython/rev/149be7000c11
History
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 64962
2014-03-17 06:31:11python-devsetmessages: + msg213832
2014-03-13 10:15:55berker.peksagsetstage: commit review -> resolved
2014-02-26 23:29:53brett.cannonsetmessages: + msg212328
2014-02-26 23:29:34brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg212327
2014-02-26 23:28:44brett.cannonlinkissue20789 dependencies
2014-02-26 23:26:56python-devsetnosy: + python-dev
messages: + msg212325
2014-02-26 15:20:11brett.cannonsetmessages: + msg212261
2014-02-26 13:45:24ynkdirsetmessages: + msg212254
2014-02-26 04:47:30Arfreversetnosy: + Arfrever
2014-02-26 02:10:33eric.snowsetmessages: + msg212234
2014-02-26 01:02:10brett.cannonsetfiles: + issue_20763.diff
keywords: + patch
messages: + msg212233

stage: commit review
2014-02-26 00:11:04brett.cannonsetassignee: brett.cannon
2014-02-25 23:56:19brett.cannonsetmessages: + msg212229
2014-02-25 16:54:34brett.cannonsetmessages: + msg212190
2014-02-25 16:51:28brett.cannonsetmessages: + msg212189
2014-02-25 15:19:08matejciksetnosy: + matejcik
2014-02-25 14:23:44r.david.murraysetpriority: normal -> release blocker
nosy: + larry
2014-02-25 11:49:03berker.peksagsetnosy: + eric.snow
2014-02-25 09:49:03donmezsetnosy: + donmez
2014-02-25 04:04:46yselivanovsetnosy: + yselivanov
2014-02-25 04:04:11yselivanovsetnosy: + brett.cannon
2014-02-25 03:36:04ynkdircreate