From 5e5771d1d5334b973e4339be625d11a1f640b1ab Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 17 Oct 2025 11:55:14 +0300 Subject: [PATCH 1/2] gh-140241: Fix documentation for the registry parameter of warnings.warn_explicit() --- Doc/library/warnings.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index f9c8c4fc3a804e..ce02d3dafb01b2 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -480,14 +480,19 @@ Available Functions .. 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 - explicitly the message, category, filename and line number, and optionally the - module name and the registry (which should be the ``__warningregistry__`` - dictionary of the module). The module name defaults to the filename with - ``.py`` stripped; if no registry is passed, the warning is never suppressed. + explicitly the message, category, filename and line number, and optionally + other arguments. *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 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. + *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 source for modules found in zipfiles or other non-filesystem import From 62a942540a12f009e2cedaa19816a61491837cac Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 17 Oct 2025 13:25:22 +0300 Subject: [PATCH 2/2] Update Doc/library/warnings.rst Co-authored-by: Petr Viktorin --- Doc/library/warnings.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index ce02d3dafb01b2..03b7a8dc378ef3 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -491,7 +491,9 @@ Available Functions *registry*, if supplied, should be the ``__warningregistry__`` dictionary of the module. - If no registry is passed, each warning is treated as the first occurrence. + 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 for which the warning is issued. (This argument is used to support displaying