diff options
author | Georg Brandl <georg@python.org> | 2010-10-24 15:11:22 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-10-24 15:11:22 (GMT) |
commit | 08be72d0aa0112118b79d271479598c218adfd23 (patch) | |
tree | 5c885e7f573248c725915ed00f4a0476daa7a556 /Objects/exceptions.c | |
parent | 872a702bbd3c471278e07d773f7a5a49eb9dc5b2 (diff) | |
download | cpython-08be72d0aa0112118b79d271479598c218adfd23.zip cpython-08be72d0aa0112118b79d271479598c218adfd23.tar.gz cpython-08be72d0aa0112118b79d271479598c218adfd23.tar.bz2 |
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.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index b82b6ba..5715b26 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1852,6 +1852,7 @@ SimpleExtendsException(PyExc_Warning, UnicodeWarning, "Base class for warnings about Unicode related problems, mostly\n" "related to conversion problems."); + /* * BytesWarning extends Warning */ @@ -1860,6 +1861,13 @@ SimpleExtendsException(PyExc_Warning, BytesWarning, "related to conversion from str or comparing to str."); +/* + * ResourceWarning extends Warning + */ +SimpleExtendsException(PyExc_Warning, ResourceWarning, + "Base class for warnings about resource usage."); + + /* Pre-computed MemoryError instance. Best to create this as early as * possible and not wait until a MemoryError is actually raised! @@ -1939,6 +1947,7 @@ _PyExc_Init(void) PRE_INIT(ImportWarning) PRE_INIT(UnicodeWarning) PRE_INIT(BytesWarning) + PRE_INIT(ResourceWarning) bltinmod = PyImport_ImportModule("builtins"); if (bltinmod == NULL) @@ -2001,6 +2010,7 @@ _PyExc_Init(void) POST_INIT(ImportWarning) POST_INIT(UnicodeWarning) POST_INIT(BytesWarning) + POST_INIT(ResourceWarning) PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL); if (!PyExc_MemoryErrorInst) |