Skip to content

gh-153128: Preserve once warnings across filter changes - #153697

Open
snoopuppy582 wants to merge 1 commit into
python:mainfrom
snoopuppy582:fix/warnings-once-filter-change
Open

snoopuppy582 wants to merge 1 commit into
python:mainfrom
snoopuppy582:fix/warnings-once-filter-change

Conversation

@snoopuppy582

@snoopuppy582 snoopuppy582 commented Jul 14, 2026 •

Copy link
Copy Markdown

Adding an unrelated warning filter makes the C implementation emit a "once" warning a second time. The pure Python implementation emits it once.

Keep the location-specific entry in the module's versioned registry. For "once", record (text, category) in the shared once registry under its dictionary critical section, using the existing registry_add() helper. This lets the entry survive changes to the filters.

The regression test runs against both implementations. On main it fails for C (two emissions) and passes for Python. Both pass with this change. On a Linux debug build, test_warnings also passed in default mode, with -X context_aware_warnings=1, and under the -R 3:3 reference-leak check.

Fixes #153128.

AI assistance

OpenAI Codex assisted with research, reproduction, the implementation and regression test, local verification, and this description.

@python-cla-bot

python-cla-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Keep the C implementation's once registry independent of filter version changes, matching the pure Python implementation. Add a shared regression test and a Library news entry.
@snoopuppy582
snoopuppy582 force-pushed the fix/warnings-once-filter-change branch from be739c1 to 36736e0 Compare November 25, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

warnings: adding new filter resets prior existing "once" filters

1 participant