Skip to content

Implementation for PEP 451 (importlib.machinery.ModuleSpec) #63064

Closed

Description

@ericsnowcurrently
BPO 18864
Nosy @brettcannon, @terryjreedy, @ncoghlan, @larryhastings, @PCManticore, @ericsnowcurrently, @berkerpeksag, @phmc
Dependencies
  • bpo-19697: Document the possible values for main.spec
  • bpo-19700: Update runpy for PEP 451
  • bpo-19701: Update multiprocessing for PEP 451
  • bpo-19703: Update pydoc to PEP 451
  • bpo-19704: Update test.test_threaded_import to PEP 451
  • bpo-19705: Update test.test_namespace_pkgs to PEP 451
  • bpo-19706: Check if inspect needs updating for PEP 451
  • bpo-19707: Check if unittest.mock needs updating for PEP 451
  • bpo-19708: Check pkgutil for anything missing for PEP 451
  • bpo-19709: Check pythonrun.c is fully using PEP 451
  • bpo-19710: Make sure documentation for PEP 451 is finished
  • bpo-19711: add test for changed portions after reloading a namespace package
  • bpo-19712: Make sure there are exec_module tests for _LoaderBasics subclasses
  • bpo-19713: Deprecate various things in importlib thanks to PEP 451
  • bpo-19714: Add tests for importlib.machinery.WindowsRegistryFinder
  • bpo-21098: Address remaining PEP 451-related to-do comments.
  • bpo-21099: Switch applicable importlib tests to use PEP 451 API
  • Files
  • modulespec-initial.diff
  • import-system-reference.diff
  • modulespec-primary-changes.diff
  • issue18864-has-location-setter.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/ericsnowcurrently'
    closed_at = <Date 2016-05-12.14:37:11.280>
    created_at = <Date 2013-08-28.06:56:18.238>
    labels = ['interpreter-core', 'deferred-blocker', 'type-feature', 'library']
    title = 'Implementation for PEP 451 (importlib.machinery.ModuleSpec)'
    updated_at = <Date 2016-05-12.14:37:11.278>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2016-05-12.14:37:11.278>
    actor = 'eric.snow'
    assignee = 'eric.snow'
    closed = True
    closed_date = <Date 2016-05-12.14:37:11.280>
    closer = 'eric.snow'
    components = ['Interpreter Core', 'Library (Lib)']
    creation = <Date 2013-08-28.06:56:18.238>
    creator = 'eric.snow'
    dependencies = ['19697', '19700', '19701', '19703', '19704', '19705', '19706', '19707', '19708', '19709', '19710', '19711', '19712', '19713', '19714', '21098', '21099']
    files = ['31959', '32381', '32457', '33073']
    hgrepos = []
    issue_num = 18864
    keywords = ['patch']
    message_count = 66.0
    messages = ['196352', '198981', '201210', '201212', '201224', '201244', '201369', '201399', '201604', '201605', '201946', '202456', '202461', '202482', '202483', '202655', '202656', '202657', '202658', '202659', '202660', '202661', '202662', '202663', '202664', '202669', '202672', '202673', '202676', '202681', '202695', '202710', '202711', '202712', '202917', '202918', '203329', '203340', '203411', '203578', '203649', '203800', '203801', '203810', '203811', '203825', '203831', '203835', '203843', '205384', '205520', '205575', '205576', '205769', '205822', '205881', '207509', '207510', '210927', '210957', '215152', '221905', '221932', '222289', '236537', '265408']
    nosy_count = 11.0
    nosy_names = ['brett.cannon', 'terry.reedy', 'ncoghlan', 'larry', 'Arfrever', 'Claudiu.Popa', 'BreamoreBoy', 'python-dev', 'eric.snow', 'berker.peksag', 'pconnell']
    pr_nums = []
    priority = 'deferred blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue18864'
    versions = ['Python 3.4']

    Activity

    1. ericsnowcurrently commented on Aug 28, 2013

      @ericsnowcurrently
      MemberAuthor

      This ticket will track the implementation for PEP-451 (ModuleSpec). I'll have a patch up in the next couple days.

    2. added
      interpreter-core
      stdlib
      type-feature
      on Aug 28, 2013
    3. ericsnowcurrently commented on Oct 5, 2013

      @ericsnowcurrently
      MemberAuthor

      Here's an initial patch. Some key things left to do:

      • unit tests
      • documentation
      • implement exec_module() for the various importlib loaders.

      Once that's squared away there are further things that will be addressed in new tickets (or at least separate patches). This includes:

      • remove init_module_attrs() and module_to_load()
      • deprecations
      • clear a bunch of helper functions out of _bootstrap.py
      • use ModuleSpec with __main__
      • address impact on stdlib (pkgutil, pickle, etc.)
    4. ericsnowcurrently commented on Oct 25, 2013

      @ericsnowcurrently
      MemberAuthor

      Here's a patch just for the changes to the import page in the language reference. It's not perfect, but should represent the target pretty closely.

    5. ericsnowcurrently commented on Oct 25, 2013

      @ericsnowcurrently
      MemberAuthor

      Let's try that again with the proper diff. :)

    6. ncoghlan commented on Oct 25, 2013

      @ncoghlan
      Contributor

      Thanks, that looks pretty good - so much less work for loaders to do.

      After this, we may even be able to finally fix the circular import bug and the one where submodule imports succeed but the overall package import fails.

    7. brettcannon commented on Oct 25, 2013

      @brettcannon
      Member

      I've added a review

    8. ncoghlan commented on Oct 26, 2013

      @ncoghlan
      Contributor

      Something else we may be able to fix (albeit probably not in 3.4): several of the issues noted in PEP-395 (since __main__.__spec__.name will give the real module name, even when __name__ is set to "__main__" or otherwise modified)

    9. ericsnowcurrently commented on Oct 26, 2013

      @ericsnowcurrently
      MemberAuthor

      Here's an update of the language reference patch based on Brett's comments.

    10. ericsnowcurrently commented on Oct 29, 2013

      @ericsnowcurrently
      MemberAuthor

      Here's an updated patch that implements the meat of the current PEP. Docs are still lacking and I could probably add a few more tests. Other key things left to do:

      • deprecations and removals
      • refactor importlib finders and loaders to use the new Finder/Loader APIs
      • refactor pythonrun.c to make use of __spec__
      • adjust other APIs to use __spec__ (pickle, etc.)
    11. ericsnowcurrently commented on Oct 29, 2013

      @ericsnowcurrently
      MemberAuthor

      This time against tip. :)

      I should also point out that this patch is on top of the path in bpo-19413.

    12. ericsnowcurrently commented on Nov 1, 2013

      @ericsnowcurrently
      MemberAuthor

      Here's a new patch that is mostly up to date with the PEP. I still need to work on Docs and add more tests. There are a few failing tests (due to the recent reload patch) that I need to fix when I get a minute.

      This patch also implements find_spec() on FileFinder and PathFinder. Left to do:

      • deprecations and removals
      • refactor importlib loaders to use the new Finder/Loader APIs
      • refactor pythonrun.c to make use of __spec__
      • adjust other APIs to use __spec__ (pickle, etc.)
    13. 45 remaining items

    14. ericsnowcurrently commented on Dec 10, 2013

      @ericsnowcurrently
      MemberAuthor

      Here's a patch for adding a setter for ModuleSpec.has_location.

    15. brettcannon commented on Dec 10, 2013

      @brettcannon
      Member

      LGTM

    16. python-dev commented on Dec 11, 2013

      python-devmannequin
      Mannequin

      New changeset e961a166dc70 by Eric Snow in branch 'default':
      Issue bpo-18864: Add a setter for ModuleSpec.has_location.
      http://hg.python.org/cpython/rev/e961a166dc70

    17. ericsnowcurrently commented on Jan 7, 2014

      @ericsnowcurrently
      MemberAuthor

      About the only thing left for this ticket is to finish up writing a few tests and round out some documentation.

    18. ericsnowcurrently commented on Jan 7, 2014

      @ericsnowcurrently
      MemberAuthor

      There are a few lingering to-do comments that will need to be addressed as part of the remaining work:

      Lib/test/test_importlib/extension/test_case_sensitivity.py:# XXX find_spec tests
      Lib/test/test_importlib/extension/test_finder.py:# XXX find_spec tests
      Lib/test/test_importlib/source/test_file_loader.py: mod = loader.load_module('_temp') # XXX
      Lib/test/test_importlib/source/test_file_loader.py: # XXX Change to use exec_module().
      Lib/test/test_importlib/test_windows.py: # XXX Need a test that finds the spec via the registry.

    19. terryjreedy commented on Feb 11, 2014

      @terryjreedy
      Member

      Failure with 3.4.0c1:

      [170/394/5] test_importlib
      test test_importlib failed -- Traceback (most recent call last):
        File "C:\Programs\Python34.32\lib\unittest\case.py", line 57, in testPartExecutor
          yield
        File "C:\Programs\Python34.32\lib\unittest\case.py", line 574, in run
          testMethod()
        File "C:\Programs\Python34.32\lib\unittest\loader.py", line 32, in testFailure
          raise exception
      ImportError: Failed to import test module: test.test_importlib.source.test_abc_loader
      Traceback (most recent call last):
        File "C:\Programs\Python34.32\lib\unittest\loader.py", line 312, in _find_tests
          module = self._get_module_from_name(name)
        File "C:\Programs\Python34.32\lib\unittest\loader.py", line 290, in _get_module_from_name
          __import__(name)
        File "C:\Programs\Python34.32\lib\test\test_importlib\source\test_abc_loader.py", line 73, in <module>
          class PyLoaderMock(abc.PyLoader):
      AttributeError: 'module' object has no attribute 'PyLoader'

      On the other hand, the test passes on a fresh debug build.

    20. brettcannon commented on Feb 11, 2014

      @brettcannon
      Member

      Terry has admitted in other bugs he filed that he didn't use a fresh install location, so the test failure is most likely a red herring.

    21. ericsnowcurrently commented on Mar 29, 2014

      @ericsnowcurrently
      MemberAuthor

      I've gone ahead and moved all remaining work into separate issues. Once the 4 remaining sub-issues are resolved, this one can be closed. I've *finally* got a couple days free so I want to close this out. :)

    22. BreamoreBoy commented on Jun 29, 2014

      BreamoreBoymannequin
      Mannequin

      Given that PEP-451 is listed in the "Finished PEPs (done, implemented in code repository)" section of the PEP index can we close this and associated issues out?

    23. terryjreedy commented on Jun 30, 2014

      @terryjreedy
      Member

      Dependencies 19711 and 21099 are still open.

    24. BreamoreBoy commented on Jul 4, 2014

      BreamoreBoymannequin
      Mannequin

      I've asked for patch reviewss on the three dependencies outstanding, bpo-19711, bpo-19714 and bpo-21099.

    25. BreamoreBoy commented on Feb 24, 2015

      BreamoreBoymannequin
      Mannequin

      I've asked for updates on the two remaining dependencies bpo-19711 and bpo-21099.

    26. ericsnowcurrently commented on May 12, 2016

      @ericsnowcurrently
      MemberAuthor

      The last dependencies have now been closed!

    27. 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

    Labels

    deferred-blockerinterpreter-corestdlibtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions