-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Consider the following code snippet as a MWE
import logging
import warnings
def emit_user_warning() -> None:
"""Trigger the warning that we expect pytest-style helpers to see."""
warnings.warn('MWE warning', UserWarning)
def main() -> None:
"""Log the warning while capturing it via ``warnings.catch_warnings``."""
logging.captureWarnings(True)
warnings.simplefilter('always', UserWarning)
with warnings.catch_warnings(record=True) as recorded:
emit_user_warning()
print('warnings captured inside catch_warnings:', len(recorded))
for entry in recorded:
print(' captured message:', entry.message)
if __name__ == '__main__':
main()Executing this script with python3.14 will generate the following output:
$ `uv python find 3.14` nogil_warning_capture.py
warnings captured inside catch_warnings: 1
captured message: MWE warningwhile the output on python3.14t will be:
$ `uv python find 3.14t` nogil_warning_capture.py
warnings captured inside catch_warnings: 0
I am actually expecting the behavior of 3.14 to be the correct one.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error