mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
872a702bbd
commit
08be72d0aa
12 changed files with 80 additions and 30 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue