diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-11-20 17:47:03 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2017-11-20 17:47:03 (GMT) |
commit | 895862aa01793a26e74512befb0c66a1da2587d6 (patch) | |
tree | a65de848905ccd0541e15ca5584d69800e264ecf /Lib/warnings.py | |
parent | c5a2071586f735d2a61d1756e7011cfbb6ce86c9 (diff) | |
download | cpython-895862aa01793a26e74512befb0c66a1da2587d6.zip cpython-895862aa01793a26e74512befb0c66a1da2587d6.tar.gz cpython-895862aa01793a26e74512befb0c66a1da2587d6.tar.bz2 |
bpo-32088: Display Deprecation in debug mode (#4474)
When Python is build is debug mode (Py_DEBUG), DeprecationWarning,
PendingDeprecationWarning and ImportWarning warnings are now
displayed by default.
test_venv: run "-m pip" and "-m ensurepip._uninstall" with -W
ignore::DeprecationWarning since pip code is not part of Python.
Diffstat (limited to 'Lib/warnings.py')
-rw-r--r-- | Lib/warnings.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index a1f7746..48d5e16 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -508,10 +508,13 @@ except ImportError: # Module initialization _processoptions(sys.warnoptions) if not _warnings_defaults: - silence = [ImportWarning, PendingDeprecationWarning] - silence.append(DeprecationWarning) - for cls in silence: - simplefilter("ignore", category=cls) + py_debug = hasattr(sys, 'gettotalrefcount') + if not py_debug: + silence = [ImportWarning, PendingDeprecationWarning] + silence.append(DeprecationWarning) + for cls in silence: + simplefilter("ignore", category=cls) + bytes_warning = sys.flags.bytes_warning if bytes_warning > 1: bytes_action = "error" @@ -520,8 +523,9 @@ if not _warnings_defaults: else: bytes_action = "ignore" simplefilter(bytes_action, category=BytesWarning, append=1) + # resource usage warnings are enabled by default in pydebug mode - if hasattr(sys, 'gettotalrefcount'): + if py_debug: resource_action = "always" else: resource_action = "ignore" |