Compare commits

...

2 commits

Author SHA1 Message Date
Miss Islington (bot)
762fbdbf8c
[3.13] gh-140241: Fix documentation for the registry parameter of warnings.warn_explicit() (GH-140242) (GH-140293)
(cherry picked from commit 78e1d65a4d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-10-18 11:03:03 +00:00
Serhiy Storchaka
0231a391f9
[3.13] gh-140272: Fix memory leak in _gdbm.gdbm.clear() (GH-140274) (GH-140289)
(cherry picked from commit f937468e7c)

Co-authored-by: Shamil <ashm.tech@proton.me>
2025-10-18 11:00:10 +00:00
3 changed files with 14 additions and 4 deletions

View file

@ -469,14 +469,21 @@ Available Functions
.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, source=None) .. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, source=None)
This is a low-level interface to the functionality of :func:`warn`, passing in This is a low-level interface to the functionality of :func:`warn`, passing in
explicitly the message, category, filename and line number, and optionally the explicitly the message, category, filename and line number, and optionally
module name and the registry (which should be the ``__warningregistry__`` other arguments.
dictionary of the module). The module name defaults to the filename with
``.py`` stripped; if no registry is passed, the warning is never suppressed.
*message* must be a string and *category* a subclass of :exc:`Warning` or *message* must be a string and *category* a subclass of :exc:`Warning` or
*message* may be a :exc:`Warning` instance, in which case *category* will be *message* may be a :exc:`Warning` instance, in which case *category* will be
ignored. ignored.
*module*, if supplied, should be the module name.
If no module is passed, the filename with ``.py`` stripped is used.
*registry*, if supplied, should be the ``__warningregistry__`` dictionary
of the module.
If no registry is passed, each warning is treated as the first occurrence,
that is, filter actions ``"default"``, ``"module"`` and ``"once"`` are
handled as ``"always"``.
*module_globals*, if supplied, should be the global namespace in use by the code *module_globals*, if supplied, should be the global namespace in use by the code
for which the warning is issued. (This argument is used to support displaying for which the warning is issued. (This argument is used to support displaying
source for modules found in zipfiles or other non-filesystem import source for modules found in zipfiles or other non-filesystem import

View file

@ -0,0 +1 @@
Fix memory leak in the :meth:`!clear` method of the :mod:`dbm.gnu` database.

View file

@ -612,8 +612,10 @@ _gdbm_gdbm_clear_impl(gdbmobject *self, PyTypeObject *cls)
} }
if (gdbm_delete(self->di_dbm, key) < 0) { if (gdbm_delete(self->di_dbm, key) < 0) {
PyErr_SetString(state->gdbm_error, "cannot delete item from database"); PyErr_SetString(state->gdbm_error, "cannot delete item from database");
free(key.dptr);
return NULL; return NULL;
} }
free(key.dptr);
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }