Skip to content

importlib.abc: NameError: name 'warnings' is not defined #121279

Description

@hroncok

Bug report

Bug description:

>>> import importlib.abc
>>> importlib.abc.TraversableResources
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    importlib.abc.TraversableResources
  File "/usr/lib64/python3.13/importlib/abc.py", line 34, in __getattr__
    warnings._deprecated(f"{__name__}.{name}", remove=(3, 14))
    ^^^^^^^^
NameError: name 'warnings' is not defined. Did you mean: 'Warning'? Or did you forget to import 'warnings'?

This is a result of #120429

Thew change on the main branch correctly removed unused import warnings, but ti got backported to 3.13 where the import is used.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Jul 2, 2024
  2. hroncok commented on Jul 2, 2024

    @hroncok
    ContributorAuthor

    Working on a PR.

  3. added 2 commits that reference this issue on Jul 2, 2024
  4. added a commit that references this issue on Jul 3, 2024
  5. vstinner commented on Jul 3, 2024

    @vstinner
    Member

    Fixed by dacf4ff.

  6. encukou commented on Jul 3, 2024

    @encukou
    Member

    The fix fails in refleaks buildbots:

    Reproducible with:

    ./python -m test test_importlib -m 'test_deprecated*' -R:
    
  7. reopened this on Jul 3, 2024
  8. hroncok commented on Jul 3, 2024

    @hroncok
    ContributorAuthor

    The failure is AssertionError: DeprecationWarning not triggered

    I assume that when the test runs multiple times, the DeprecationWarning is no longer triggered. I would need to see how other tests do this.

  9. added a commit that references this issue on Jul 3, 2024
  10. vstinner commented on Jul 3, 2024

    @vstinner
    Member

    The fix fails in refleaks buildbots:

    I propose a fix for that: #121319

  11. hroncok commented on Jul 3, 2024

    @hroncok
    ContributorAuthor

    Apologies for breaking the buildbots. TIL I need to run my tests with -R: to check this.

  12. vstinner commented on Jul 3, 2024

    @vstinner
    Member

    It's uncommon that tests only fail with -R, don't worry.

  13. added a commit that references this issue on Jul 3, 2024
  14. vstinner commented on Jul 3, 2024

    @vstinner
    Member

    The fix fails in refleaks buildbots:

    It should be fixed by: ec0f801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions