mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
bpo-27535: Fix memory leak with warnings ignore (#4489)
The warnings module doesn't leak memory anymore in the hidden warnings registry for the "ignore" action of warnings filters. The warn_explicit() function doesn't add the warning key to the registry anymore for the "ignore" action.
This commit is contained in:
parent
21c7730761
commit
c9758784eb
4 changed files with 14 additions and 5 deletions
|
@ -528,16 +528,21 @@ warn_explicit(PyObject *category, PyObject *message,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (_PyUnicode_EqualToASCIIString(action, "ignore")) {
|
||||
goto return_none;
|
||||
}
|
||||
|
||||
/* Store in the registry that we've been here, *except* when the action
|
||||
is "always". */
|
||||
rc = 0;
|
||||
if (!_PyUnicode_EqualToASCIIString(action, "always")) {
|
||||
if (registry != NULL && registry != Py_None &&
|
||||
PyDict_SetItem(registry, key, Py_True) < 0)
|
||||
PyDict_SetItem(registry, key, Py_True) < 0)
|
||||
{
|
||||
goto cleanup;
|
||||
else if (_PyUnicode_EqualToASCIIString(action, "ignore"))
|
||||
goto return_none;
|
||||
else if (_PyUnicode_EqualToASCIIString(action, "once")) {
|
||||
}
|
||||
|
||||
if (_PyUnicode_EqualToASCIIString(action, "once")) {
|
||||
if (registry == NULL || registry == Py_None) {
|
||||
registry = get_once_registry();
|
||||
if (registry == NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue