Skip to content

Make sure all deprecated items in importlib raise DeprecationWarning #121604

Activity

  1. changed the title [-]Make sure all deprecated items inimportlib[/-] [+]Make sure all deprecated items in importlib raise `DeprecationWarning`[/+] on Jul 10, 2024
  2. rashansmith commented on Jul 13, 2024

    @rashansmith
    Contributor

    I will try this one at europython :)

  3. tomasr8 commented on Jul 13, 2024

    @tomasr8
    Member

    @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}'")

  4. rashansmith commented on Jul 13, 2024

    @rashansmith
    Contributor

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

  5. willingc commented on Jul 13, 2024

    @willingc
    Contributor

    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

  6. bedevere-app commented on Jul 14, 2024

    @bedevere-app

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

  7. rashansmith commented on Jul 14, 2024

    @rashansmith
    Contributor

    @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:

  8. brettcannon commented on Jul 15, 2024

    @brettcannon
    MemberAuthor

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

  9. self-assigned this
    on Sep 26, 2024
  10. tungol commented on Dec 16, 2024

    @tungol
    Contributor

    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.

  11. tomasr8 commented on Dec 16, 2024

    @tomasr8
    Member

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

  12. tungol commented on Dec 16, 2024

    @tungol
    Contributor

    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.

  13. added 3 commits that reference this issue on Jan 15, 2025
  14. tomasr8 commented on Feb 8, 2025

    @tomasr8
    Member

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

  15. willingc commented on Feb 10, 2025

    @willingc
    Contributor

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

  16. deleted a comment from on Feb 11, 2025
  17. brettcannon commented on Feb 11, 2025

    @brettcannon
    MemberAuthor

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

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