From 08be72d0aa0112118b79d271479598c218adfd23 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 24 Oct 2010 15:11:22 +0000 Subject: Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default, except when configured --with-pydebug. Emit this warning from the GC shutdown procedure, rather than just printing to stderr. --- Lib/warnings.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/warnings.py') diff --git a/Lib/warnings.py b/Lib/warnings.py index a81aab3fe5..5b5821b1c3 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -383,4 +383,11 @@ 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'): + resource_action = "always" + else: + resource_action = "ignore" + simplefilter(resource_action, category=ResourceWarning, append=1) + del _warnings_defaults -- cgit v1.2.1