From b45319e13273ee17e84e6b8c459f03b141518289 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 10 May 2026 13:43:57 -0700 Subject: [PATCH 1/3] gh-139489: Add is_valid_text to xml.__all__ (#149641) --- Lib/xml/__init__.py | 2 +- .../next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst diff --git a/Lib/xml/__init__.py b/Lib/xml/__init__.py index 002d6d3e0e8267..ecfce1c6ae52cf 100644 --- a/Lib/xml/__init__.py +++ b/Lib/xml/__init__.py @@ -18,4 +18,4 @@ from .utils import * -__all__ = ["dom", "parsers", "sax", "etree", "is_valid_name"] +__all__ = ["dom", "parsers", "sax", "etree", "is_valid_name", "is_valid_text"] diff --git a/Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst b/Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst new file mode 100644 index 00000000000000..40fe7e9fd6a008 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-05-10-07-21-51.gh-issue-139489.rS7LTA.rst @@ -0,0 +1 @@ +Add :func:`xml.is_valid_text` to ``xml.__all__``. From c6fd7de64ac7591a9708c14a34737eb9baf050bc Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 11 May 2026 01:22:16 +0300 Subject: [PATCH 2/3] gh-149083: use sentinel to fix _functools.reduce() signature (#149591) --- Lib/inspect.py | 3 ++- Lib/test/test_inspect/test_inspect.py | 3 +-- Modules/_functoolsmodule.c | 4 ++-- Modules/clinic/_functoolsmodule.c.h | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Lib/inspect.py b/Lib/inspect.py index 3e85625cd30263..af6aa3eb37a53b 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2207,7 +2207,8 @@ def wrap_value(s): except NameError: raise ValueError - if isinstance(value, (str, int, float, bytes, bool, type(None))): + if isinstance(value, (str, int, float, bytes, bool, type(None), + sentinel)): return ast.Constant(value) raise ValueError diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py index 9028d42c617fb4..7351f97fd9a4b5 100644 --- a/Lib/test/test_inspect/test_inspect.py +++ b/Lib/test/test_inspect/test_inspect.py @@ -6255,8 +6255,7 @@ def test_faulthandler_module_has_signatures(self): self._test_module_has_signatures(faulthandler, unsupported_signature=unsupported_signature) def test_functools_module_has_signatures(self): - unsupported_signature = {"reduce"} - self._test_module_has_signatures(functools, unsupported_signature=unsupported_signature) + self._test_module_has_signatures(functools) def test_gc_module_has_signatures(self): import gc diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 19bdf3d47c2fad..c702eecc700ac8 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1066,7 +1066,7 @@ _functools.reduce function as func: object iterable as seq: object / - initial as result: object = NULL + initial as result: object(c_default="NULL") = functools._initial_missing Apply a function of two arguments cumulatively to the items of an iterable, from left to right. @@ -1081,7 +1081,7 @@ calculates ((((1 + 2) + 3) + 4) + 5). static PyObject * _functools_reduce_impl(PyObject *module, PyObject *func, PyObject *seq, PyObject *result) -/*[clinic end generated code: output=30d898fe1267c79d input=4ccfb74548ce5170]*/ +/*[clinic end generated code: output=30d898fe1267c79d input=5c9088c98ffe2793]*/ { PyObject *args, *it; diff --git a/Modules/clinic/_functoolsmodule.c.h b/Modules/clinic/_functoolsmodule.c.h index 23f66631085031..87cdef2ad3cff3 100644 --- a/Modules/clinic/_functoolsmodule.c.h +++ b/Modules/clinic/_functoolsmodule.c.h @@ -71,7 +71,8 @@ _functools_cmp_to_key(PyObject *module, PyObject *const *args, Py_ssize_t nargs, } PyDoc_STRVAR(_functools_reduce__doc__, -"reduce($module, function, iterable, /, initial=)\n" +"reduce($module, function, iterable, /,\n" +" initial=functools._initial_missing)\n" "--\n" "\n" "Apply a function of two arguments cumulatively to the items of an iterable, from left to right.\n" @@ -192,4 +193,4 @@ _functools__lru_cache_wrapper_cache_clear(PyObject *self, PyObject *Py_UNUSED(ig return return_value; } -/*[clinic end generated code: output=7f2abc718fcc35d5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ac9e26d0a5a23d40 input=a9049054013a1b77]*/ From c1dbd51fac072e6008941fb22d89b9fe390c2b24 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 11 May 2026 03:05:56 +0300 Subject: [PATCH 3/3] gh-149598: Remove `strm` argument support from `logging` handlers (#149599) gh-149598: Remove *strm* argument support from `logging` handlers --- Doc/whatsnew/3.16.rst | 7 ++++++ Lib/logging/config.py | 23 +------------------ Lib/test/test_logging.py | 18 +++++---------- ...-05-09-15-17-59.gh-issue-149598.aLrXRw.rst | 1 + 4 files changed, 15 insertions(+), 34 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst index d9beda92aba6a3..967b3baf530a51 100644 --- a/Doc/whatsnew/3.16.rst +++ b/Doc/whatsnew/3.16.rst @@ -120,6 +120,13 @@ functools * Calling the Python implementation of :func:`functools.reduce` with *function* or *sequence* as keyword arguments has been deprecated since Python 3.14. +logging +------- + +* Support for custom logging handlers with the *strm* argument is deprecated + and scheduled for removal in Python 3.16. Define handlers with the *stream* + argument instead. + symtable -------- diff --git a/Lib/logging/config.py b/Lib/logging/config.py index 3d9aa00fa52d11..9a8b7016886eee 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -865,28 +865,7 @@ def configure_handler(self, config): else: factory = klass kwargs = {k: config[k] for k in config if (k != '.' and valid_ident(k))} - # When deprecation ends for using the 'strm' parameter, remove the - # "except TypeError ..." - try: - result = factory(**kwargs) - except TypeError as te: - if "'stream'" not in str(te): - raise - #The argument name changed from strm to stream - #Retry with old name. - #This is so that code can be used with older Python versions - #(e.g. by Django) - kwargs['strm'] = kwargs.pop('stream') - result = factory(**kwargs) - - import warnings - warnings.warn( - "Support for custom logging handlers with the 'strm' argument " - "is deprecated and scheduled for removal in Python 3.16. " - "Define handlers with the 'stream' argument instead.", - DeprecationWarning, - stacklevel=2, - ) + result = factory(**kwargs) if formatter: result.setFormatter(formatter) if level is not None: diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 1a76c2173a3011..f2cbc2514fce53 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -3297,12 +3297,11 @@ def format(self, record): } } - # Remove when deprecation ends. - class DeprecatedStrmHandler(logging.StreamHandler): + class StrmHandler(logging.StreamHandler): def __init__(self, strm=None): super().__init__(stream=strm) - config_custom_handler_with_deprecated_strm_arg = { + config_custom_handler_with_removed_strm_arg = { "version": 1, "formatters": { "form1": { @@ -3311,7 +3310,7 @@ def __init__(self, strm=None): }, "handlers": { "hand1": { - "class": DeprecatedStrmHandler, + "class": StrmHandler, "formatter": "form1", "level": "NOTSET", "stream": "ext://sys.stdout", @@ -3417,14 +3416,9 @@ def test_config5_ok(self): self.test_config1_ok(config=self.config5) self.check_handler('hand1', CustomHandler) - def test_deprecation_warning_custom_handler_with_strm_arg(self): - msg = ( - "Support for custom logging handlers with the 'strm' argument " - "is deprecated and scheduled for removal in Python 3.16. " - "Define handlers with the 'stream' argument instead." - ) - with self.assertWarnsRegex(DeprecationWarning, msg): - self.test_config1_ok(config=self.config_custom_handler_with_deprecated_strm_arg) + def test_removed_strm_arg(self): + with self.assertRaisesRegex(ValueError, 'hand1'): + self.apply_config(self.config_custom_handler_with_removed_strm_arg) def test_config6_failure(self): self.assertRaises(Exception, self.apply_config, self.config6) diff --git a/Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst b/Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst new file mode 100644 index 00000000000000..8c06ba5e7d5e4e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-05-09-15-17-59.gh-issue-149598.aLrXRw.rst @@ -0,0 +1 @@ +Remove support of deprecated *strm* argument for :mod:`logging` handlers.