bpo-31975 (PEP 565): Show DeprecationWarning in __main__ · python/cpython@50abc69 · GitHub
Skip to content

Commit 50abc69

Browse files
committed
bpo-31975 (PEP 565): Show DeprecationWarning in __main__
- primary change is to add a new default filter entry for 'default::DeprecationWarning:__main__' - secondary change is an internal one to cope with plain strings in the warning module's internal filter list (this avoids the need to create a compiled regex object early on during interpreter startup)
1 parent bbdb17d commit 50abc69

3 files changed

Lines changed: 70 additions & 9 deletions

File tree

Lib/test/test_warnings/__init__.py

Lines changed: 34 additions & 1 deletion

Lib/warnings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ def _filters_mutated():
519519
# Module initialization
520520
_processoptions(sys.warnoptions)
521521
if not _warnings_defaults:
522-
# Several warning categories are ignored by default in Py_DEBUG builds
522+
# Several warning categories are ignored by default in regular builds
523523
if not hasattr(sys, 'gettotalrefcount'):
524+
filterwarnings("default", category=DeprecationWarning,
525+
module="__main__", append=1)
524526
simplefilter("ignore", category=DeprecationWarning, append=1)
525527
simplefilter("ignore", category=PendingDeprecationWarning, append=1)
526528
simplefilter("ignore", category=ImportWarning, append=1)

Python/_warnings.c

Lines changed: 33 additions & 7 deletions

0 commit comments

Comments
 (0)