Skip to content

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

Closed
ynkdir mannequin opened this issue Feb 25, 2014 · 12 comments
Closed

old sys.path_hooks importer does not work with Python 3.4.0rc1 #64962

ynkdir mannequin opened this issue Feb 25, 2014 · 12 comments
Assignees

Comments

@ynkdir
Copy link
Mannequin

ynkdir mannequin commented Feb 25, 2014

BPO 20763
Nosy @brettcannon, @larryhastings, @matejcik, @ericsnowcurrently, @1st1
Files
  • issue_20763.diff
  • 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:

    assignee = 'https://github.com/brettcannon'
    closed_at = <Date 2014-02-26.23:29:34.862>
    created_at = <Date 2014-02-25.03:36:04.270>
    labels = ['release-blocker']
    title = 'old sys.path_hooks importer does not work with Python 3.4.0rc1'
    updated_at = <Date 2014-03-17.06:31:11.561>
    user = 'https://bugs.python.org/ynkdir'

    bugs.python.org fields:

    activity = <Date 2014-03-17.06:31:11.561>
    actor = 'python-dev'
    assignee = 'brett.cannon'
    closed = True
    closed_date = <Date 2014-02-26.23:29:34.862>
    closer = 'brett.cannon'
    components = []
    creation = <Date 2014-02-25.03:36:04.270>
    creator = 'ynkdir'
    dependencies = []
    files = ['34225']
    hgrepos = []
    issue_num = 20763
    keywords = ['patch']
    message_count = 12.0
    messages = ['212158', '212189', '212190', '212229', '212233', '212234', '212254', '212261', '212325', '212327', '212328', '213832']
    nosy_count = 9.0
    nosy_names = ['brett.cannon', 'larry', 'donmez', 'matejcik', 'Arfrever', 'ynkdir', 'python-dev', 'eric.snow', 'yselivanov']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue20763'
    versions = ['Python 3.4']

    @ynkdir
    Copy link
    Mannequin Author

    ynkdir mannequin commented Feb 25, 2014

    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

    @brettcannon
    Copy link
    Member

    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.

    @brettcannon
    Copy link
    Member

    I should also mention that subclassing importlib.abc.PathEntryFinder solves this coding problem.

    @brettcannon
    Copy link
    Member

    I have a fix, I just need to create a test.

    @brettcannon brettcannon self-assigned this Feb 26, 2014
    @brettcannon
    Copy link
    Member

    Fix and test is attached. Can someone review it so I can check it in and get a cherrypick?

    @ericsnowcurrently
    Copy link
    Member

    LGTM

    @ynkdir
    Copy link
    Mannequin Author

    ynkdir mannequin commented Feb 26, 2014

    It works fine. Thank you!

    @brettcannon
    Copy link
    Member

    I'll try to commit tonight then and request a cherrypick.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 26, 2014

    New changeset 5dec1604322c by Brett Cannon in branch 'default':
    Issue bpo-20763: Fix importlib.machinery.PathFinder to support
    http://hg.python.org/cpython/rev/5dec1604322c

    @brettcannon
    Copy link
    Member

    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.

    @brettcannon
    Copy link
    Member

    Cherrypick bug is http://bugs.python.org/issue20789

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 17, 2014

    New changeset 149be7000c11 by Brett Cannon in branch '3.4':
    Issue bpo-20763: Fix importlib.machinery.PathFinder to support
    http://hg.python.org/cpython/rev/149be7000c11

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants