From cca7f38e78d5f76ce006cdfac9be1ceca4233642 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Tue, 6 Jan 2026 17:27:04 +0400 Subject: [PATCH] [3.14] gh-143331: Schedule to remove format "N" for Decimal (GH-143372) (cherry picked from commit dd750b348501247d458ea8d454213d4959a8f8b9) Co-authored-by: Semyon Moroz --- Doc/deprecations/index.rst | 2 ++ Doc/deprecations/pending-removal-in-3.18.rst | 9 +++++++++ Doc/whatsnew/3.13.rst | 5 +++++ Doc/whatsnew/3.14.rst | 2 ++ Modules/_decimal/_decimal.c | 3 ++- 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Doc/deprecations/pending-removal-in-3.18.rst diff --git a/Doc/deprecations/index.rst b/Doc/deprecations/index.rst index d064f2bec42c22..c891b0339916cb 100644 --- a/Doc/deprecations/index.rst +++ b/Doc/deprecations/index.rst @@ -7,6 +7,8 @@ Deprecations .. include:: pending-removal-in-3.17.rst +.. include:: pending-removal-in-3.18.rst + .. include:: pending-removal-in-3.19.rst .. include:: pending-removal-in-future.rst diff --git a/Doc/deprecations/pending-removal-in-3.18.rst b/Doc/deprecations/pending-removal-in-3.18.rst new file mode 100644 index 00000000000000..3e799219478424 --- /dev/null +++ b/Doc/deprecations/pending-removal-in-3.18.rst @@ -0,0 +1,9 @@ +Pending removal in Python 3.18 +------------------------------ + +* :mod:`decimal`: + + * The non-standard and undocumented :class:`~decimal.Decimal` format + specifier ``'N'``, which is only supported in the :mod:`!decimal` module's + C implementation, has been deprecated since Python 3.13. + (Contributed by Serhiy Storchaka in :gh:`89902`.) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 092af5aaa1c97a..44752d81e32606 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -1861,6 +1861,7 @@ New Deprecations * Deprecate the non-standard and undocumented :class:`~decimal.Decimal` format specifier ``'N'``, which is only supported in the :mod:`!decimal` module's C implementation. + Scheduled to be removed in Python 3.18. (Contributed by Serhiy Storchaka in :gh:`89902`.) * :mod:`dis`: @@ -2025,6 +2026,10 @@ New Deprecations .. include:: ../deprecations/pending-removal-in-3.17.rst +.. include:: ../deprecations/pending-removal-in-3.18.rst + +.. include:: ../deprecations/pending-removal-in-3.19.rst + .. include:: ../deprecations/pending-removal-in-future.rst CPython Bytecode Changes diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 5de419da57c744..5a3c0977b7d124 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -2718,6 +2718,8 @@ New deprecations .. include:: ../deprecations/pending-removal-in-3.17.rst +.. include:: ../deprecations/pending-removal-in-3.18.rst + .. include:: ../deprecations/pending-removal-in-3.19.rst .. include:: ../deprecations/pending-removal-in-future.rst diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 4516c7d847bded..a7f12e1b291e0e 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3552,7 +3552,8 @@ dec_format(PyObject *dec, PyObject *args) if (size > 0 && fmt[size-1] == 'N') { if (PyErr_WarnEx(PyExc_DeprecationWarning, - "Format specifier 'N' is deprecated", 1) < 0) { + "Format specifier 'N' is deprecated and " + "slated for removal in Python 3.18", 1) < 0) { return NULL; } }