Skip to content

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

Closed

Description

@ynkdir
mannequin
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']

    Activity

    1. ynkdir commented on Feb 25, 2014

      ynkdirmannequin
      MannequinAuthor

      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

    2. brettcannon commented on Feb 25, 2014

      @brettcannon
      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.

    3. brettcannon commented on Feb 25, 2014

      @brettcannon
      Member

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

    4. brettcannon commented on Feb 25, 2014

      @brettcannon
      Member

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

    5. self-assigned this
      on Feb 26, 2014
    6. brettcannon commented on Feb 26, 2014

      @brettcannon
      Member

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

    7. ericsnowcurrently commented on Feb 26, 2014

      @ericsnowcurrently
      Member

      LGTM

    8. ynkdir commented on Feb 26, 2014

      ynkdirmannequin
      MannequinAuthor

      It works fine. Thank you!

    9. brettcannon commented on Feb 26, 2014

      @brettcannon
      Member

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

    10. python-dev commented on Feb 26, 2014

      python-devmannequin
      Mannequin

      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

    11. brettcannon commented on Feb 26, 2014

      @brettcannon
      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.

    12. brettcannon commented on Feb 26, 2014

      @brettcannon
      Member
    13. python-dev commented on Mar 17, 2014

      python-devmannequin
      Mannequin

      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

    14. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions