gh-121163: Add "all" as an valid alias for "always" in warnings.simplefilter() (#121164)

Add support for ``all`` as an valid alias for ``always`` in ``warnings.simplefilter()``
and ``warnings.filterswarnings()``.
This commit is contained in:
Kirill Podoprigora 2024-06-30 20:48:00 +03:00 committed by GitHub
parent 2a455bbe8f
commit 1a84bdc237
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 43 deletions

View file

@ -704,9 +704,9 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message,
}
/* Store in the registry that we've been here, *except* when the action
is "always". */
is "always" or "all". */
rc = 0;
if (!_PyUnicode_EqualToASCIIString(action, "always")) {
if (!_PyUnicode_EqualToASCIIString(action, "always") && !_PyUnicode_EqualToASCIIString(action, "all")) {
if (registry != NULL && registry != Py_None &&
PyDict_SetItem(registry, key, Py_True) < 0)
{