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 — `test_warnings` fails if run with `-Werror` · Issue #122191 · python/cpython

test_warnings fails if run with -Werror #122191

New issue
Copy link
New issue
Copy link
Closed
Closed
test_warnings fails if run with -Werror#122191
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@AlexWaygood
AlexWaygood
opened on Jul 23, 2024
Issue body actions

Bug report

Bug description:

./python.exe -Werror -m test test_warnings fails, which feels sort-of ironic:

~/dev/cpython (main)⚡ % ./python.exe -We -m test test_warnings
Using random seed: 673638140
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 2.83 Run 1 test sequentially in a single process
0:00:00 load avg: 2.83 [1/1] test_warnings
test test_warnings failed -- Traceback (most recent call last):
  File "/Users/alexw/dev/cpython/Lib/test/test_warnings/__init__.py", line 904, in test_issue31285
    wmod.warn_explicit(
    ~~~~~~~~~~~~~~~~~~^
        'foo', UserWarning, 'bar', 1,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        module_globals={'__loader__': get_bad_loader(42),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        '__name__': 'foobar'})
                        ^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 934, in _bless_my_loader
DeprecationWarning: Module globals is missing a __spec__.loader

test_warnings failed (1 error)

== Tests result: FAILURE ==

1 test failed:
    test_warnings

Total duration: 482 ms
Total tests: run=146
Total test files: run=1/1 failed=1
Result: FAILURE

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-122191: Fix test_warnings failure if run with -Werror #122222
  • [3.13] gh-122191: Fix test_warnings failure if run with -Werror (GH-122222) #122256
  • [3.12] gh-122191: Fix test_warnings failure if run with -Werror (GH-122222) #122257

Activity

  1. AlexWaygood
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Jul 23, 2024
  2. x0rw commented on Jul 23, 2024

    @x0rw
    x0rw
    on Jul 23, 2024
    More actions

    Well, I spent some time tracking the error back to '/**/cpython/cpython/Lib/importlib/_bootstrap_external.py' at "_bless_my_loader," where it checks if the module globals contain loader or spec. At line 935, it raises a warning:

    _warnings.warn(
        'Module globals is missing a __spec__.loader',
        DeprecationWarning
    )
    

    Since test_warning tests warnings, it doesn't make sense to run it with --Werror, which treats warnings as errors.
    so a possible solution is to check if there is -Werror in args when runing warning tests

  3. serhiy-storchaka
    added a commit that references this issue on Jul 24, 2024

    pythongh-122191: Fix test_warnings failure if run with -Werror

    cdbc98d
  4. serhiy-storchaka commented on Jul 24, 2024

    @serhiy-storchaka
    serhiy-storchaka
    on Jul 24, 2024
    Member
    More actions

    In future, warnings will be turned into errors. Unless we are planning to remove these tests, the warnings should not be ignored.

    Reacted by Alex Waygood and x0rw
  5. serhiy-storchaka
    added a commit that references this issue on Jul 25, 2024

    gh-122191: Fix test_warnings failure if run with -Werror (GH-122222)

    9b4fe9b
  6. miss-islington
    added a commit that references this issue on Jul 25, 2024

    pythongh-122191: Fix test_warnings failure if run with -Werror (pytho…

    5c7c8f4
  7. serhiy-storchaka
    added a commit that references this issue on Jul 25, 2024

    [3.12] pythongh-122191: Fix test_warnings failure if run with -Werror (…

    8377c48
  8. serhiy-storchaka
    closed this as completedon Jul 25, 2024
  9. serhiy-storchaka
    added 2 commits that reference this issue on Jul 25, 2024

    [3.12] gh-122191: Fix test_warnings failure if run with -Werror (GH-1…

    be5e229

    [3.13] gh-122191: Fix test_warnings failure if run with -Werror (GH-1…

    94db4cc
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

    testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.