GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make sure all deprecated items in importlib raise `DeprecationWarning` · Issue #121604 · python/cpython

Make sure all deprecated items in importlib raise DeprecationWarning #121604

New issue
Copy link
New issue
Copy link
Closed
Closed
Make sure all deprecated items in importlib raise DeprecationWarning#121604
Copy link
Assignees
brettcannon
Labels
3.14bugs and security fixesbugs and security fixeseasytopic-importlib

Description

@brettcannon
brettcannon
opened on Jul 10, 2024
Issue body actions
  • importlib.abc.Loader
    • importlib.abc.InspectLoader.load_module()
    • importlib.abc.FileLoader.load_module()
    • importlib.abc.SourceLoader.load_module()
    • importlib.machinery.SourceFileLoader.load_module()
    • imortlib.machinery.SourcelessFileLoader.load_module()
  • importlib.abc.ResourceLoader
  • importlib.abc.SourceLoader.path_mtime()
  • importlib.machinery.DEBUG_BYTECODE_SUFFIXES
  • importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES
  • debug_override parameter of importlib.util.cache_from_source()

Linked PRs

  • gh-121604: Raise DeprecationWarnings in importlib #121765
  • gh-121604: Make sure all deprecated items in importlib raise DeprecationWarning #128007
  • gh-121604: fix ResourceLoader deprecation warning message #128859
  • gh-121604: fix warnings in test_importlib.test_abc and test_importlib.test_windows #128904

Activity

  1. brettcannon
    added
    topic-importlib
    3.14bugs and security fixesbugs and security fixes
    on Jul 10, 2024
  2. brettcannon
    changed the title [-]Make sure all deprecated items inimportlib[/-] [+]Make sure all deprecated items in importlib raise `DeprecationWarning`[/+] on Jul 10, 2024
  3. encukou
    added
    easy
    on Jul 13, 2024
  4. rashansmith commented on Jul 13, 2024

    @rashansmith
    rashansmith
    on Jul 13, 2024
    Contributor
    More actions

    I will try this one at europython :)

  5. tomasr8 commented on Jul 13, 2024

    @tomasr8
    tomasr8
    on Jul 13, 2024
    Member
    More actions

    @rashansmith

    To add deprecation warnings to module-level constants like DEBUG_BYTECODE_SUFFIXES I think you can use something like this:

    cpython/Lib/calendar.py

    Lines 44 to 54 in 4e36dd7

    def __getattr__(name):
    if name in ('January', 'February'):
    import warnings
    warnings.warn(f"The '{name}' attribute is deprecated, use '{name.upper()}' instead",
    DeprecationWarning, stacklevel=2)
    if name == 'January':
    return 1
    else:
    return 2
    raise AttributeError(f"module '{__name__}' has no attribute '{name}'")

  6. rashansmith commented on Jul 13, 2024

    @rashansmith
    rashansmith
    on Jul 13, 2024
    Contributor
    More actions

    @tomasr8 thanks, I've been looking at this exact file as a reference! Can you confirm which of the tasks are already done? For example in _abc.py, in the load_module() function I can already see a "# Warning implemented in _load_module_shim()." message.

  7. willingc commented on Jul 13, 2024

    @willingc
    willingc
    on Jul 13, 2024
    Contributor
    More actions

    Hi @brettcannon, I'm sitting at Europython sprints and working with @rashansmith. If you know if any of these have already been done, please let us know. Going to check the history :D

  8. bedevere-app commented on Jul 14, 2024

    @bedevere-app
    bedevere-appBot
    on Jul 14, 2024
    More actions

    GH-121765 is a backport of this pull request to the 3.14 branch.

  9. rashansmith commented on Jul 14, 2024

    @rashansmith
    rashansmith
    on Jul 14, 2024
    Contributor
    More actions

    @brettcannon @willingc @tomasr8 I've created a PR for this issue. Please let me know if it looks good or any issues I should resolve. It is based on validating which deprecationwarnings have already been implemented from the list, and therefore working on the remainders:

    •  importlib.abc.Loader
      •  importlib.abc.InspectLoader.load_module() - already done
      •  importlib.abc.FileLoader.load_module() - already done
      •  importlib.abc.SourceLoader.load_module() - already done
      •  importlib.machinery.SourceFileLoader.load_module() - already done
      •  imortlib.machinery.SourcelessFileLoader - PR
    • 
 importlib.abc.ResourceLoader PR
    • 
 importlib.abc.SourceLoader.path_mtime() PR
    • 
 importlib.machinery.DEBUG_BYTECODE_SUFFIXES PR
    • 
 importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES PR
    • 
 importlib.machinery.WindowsRegistryFinder PR
    • 
 debug_override parameter of importlib.util.cache_from_source() - already done
  10. brettcannon commented on Jul 15, 2024

    @brettcannon
    brettcannon
    on Jul 15, 2024
    MemberAuthor
    More actions

    @willingc @rashansmith I made the list from the docs based on a comment on another issue that made it sound like SourceFileLoader.load_module() wasn't raising an exception. I had not taken the time to verify anything. So thanks to @rashansmith for checking! I'll update the list based on what you found.

  11. brettcannon
    self-assigned this
    on Sep 26, 2024
  12. tungol commented on Dec 16, 2024

    @tungol
    tungol
    on Dec 16, 2024
    Contributor
    More actions

    Do we have it documented somewhere that importlib.abc.Loader is deprecated? The current importlib docs only say that importlib.abc.Loader.load_module is deprecated.

  13. tomasr8 commented on Dec 16, 2024

    @tomasr8
    tomasr8
    on Dec 16, 2024
    Member
    More actions

    I don't think it is. At least there are no deprecation warnings in the code, just for load_module.

  14. tungol commented on Dec 16, 2024

    @tungol
    tungol
    on Dec 16, 2024
    Contributor
    More actions

    That's what I thought, but I was thinking maybe I missed something given the warnings that the linked MR is adding. I'll bring the conversation over there.

  15. brettcannon
    added 3 commits that reference this issue on Jan 15, 2025

    gh-121604: Make sure all deprecated items in importlib raise Deprecat…

    bd3baa8

    gh-121604: fix ResourceLoader deprecation warning message (GH-128859)

    d05140f

    gh-121604: fix warnings in test_importlib.test_abc and test_importlib…

    27494dd
  16. tomasr8 commented on Feb 8, 2025

    @tomasr8
    tomasr8
    on Feb 8, 2025
    Member
    More actions

    All of the items mentioned in the issue now raise warnings, I think we can close this issue?

  17. willingc commented on Feb 10, 2025

    @willingc
    willingc
    on Feb 10, 2025
    Contributor
    More actions

    @brettcannon Since you opened the original issue, do you want to close this as completed? Thanks!

  18. python
    deleted a comment from on Feb 11, 2025
  19. brettcannon
    closed this as completedon Feb 11, 2025
  20. brettcannon commented on Feb 11, 2025

    @brettcannon
    brettcannon
    on Feb 11, 2025
    MemberAuthor
    More actions

    Thanks to everyone who worked on this (especially @tomasr8 for pushing it over the finish line)!

    Reacted by Hugo van Kemenade
    Reacted by Tomas R.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @brettcannon
    brettcannon

Labels

3.14bugs and security fixesbugs and security fixeseasytopic-importlib

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.