Skip to content

Add coverage for keyword arguments to warnings.warn_explicit #158146

Description

@seanabreau

warnings.warn_explicit() accepts its required message, category, filename, and lineno parameters by position or keyword, but test_warnings.WarnTests does not explicitly cover those keyword calls.

This is used by pytest's Node.warn():

import warnings

warnings.warn_explicit(
    UserWarning("probe"), category=None, filename="probe.py", lineno=7
)

CPython already handles this correctly. A RustPython compatibility bug exposed the coverage gap, and a RustPython maintainer suggested adding CPython test coverage.

Add a test to the shared WarnTests class for positional, keyword, and mixed calls with both string messages and warning instances. This exercises the C and pure-Python implementations without changing runtime behavior.

AI assistance: Codex helped prepare the test and this report.

Linked PRs

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions