From 43c8345b1bd59d289da15f8e3a1af1f4d39fe223 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Mon, 16 Feb 2026 20:32:44 -0700 Subject: [PATCH 01/20] add `%t` C99 token to strptime --- Lib/_strptime.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py index fe34808d88769a..b734954ab46bda 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -382,7 +382,9 @@ def __init__(self, locale_time=None): 'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone for tz in tz_names), 'Z'), - '%': '%'} + 't': '\t', + '%': '%' + } if self.locale_time.LC_alt_digits is None: for d in 'dmyCHIMS': mapping['O' + d] = r'(?P<%s>\d\d|\d| \d)' % d From d8382362f67ee43f56a8802d398ca748152facd7 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Mon, 16 Feb 2026 20:33:26 -0700 Subject: [PATCH 02/20] init passing tests --- Lib/test/datetimetester.py | 7 +++++++ Lib/test/test_strptime.py | 7 +++++++ Lib/test/test_time.py | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 97eec618932aa5..ddb82da01e0200 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -2207,6 +2207,13 @@ def test_strptime_D_format(self): self.theclass.strptime(test_date, "%m/%d/%y") ) + def test_strptime_t_format(self): + test_date = "2026\t02\t16" + self.assertEqual( + self.theclass.strptime(test_date, "%Y%t%m%t%d"), + self.theclass.strptime(test_date, "%Y\t%m\t%d") + ) + ############################################################################# # datetime tests diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index fd8525feb88d53..cad3bd928b7ad9 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -670,6 +670,13 @@ def test_strptime_D_format(self): time.strptime(test_date, "%m/%d/%y") ) + def test_strptime_t_format(self): + test_date = "2026\t02\t16" + self.assertEqual( + time.strptime(test_date, "%Y%t%m%t%d"), + time.strptime(test_date, "%Y\t%m\t%d") + ) + class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index da5fd16b8b6291..a96808ea182f8c 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -359,7 +359,7 @@ def test_strptime(self): # raising an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'D', 'F', 'H', 'I', - 'j', 'm', 'M', 'p', 'S', 'T', + 'j', 'm', 'M', 'p', 'S', 't', 'T', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): format = '%' + directive if directive == 'd': From a31ad125254ae81f13014cc3811f643a3c617365 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Mon, 16 Feb 2026 20:34:47 -0700 Subject: [PATCH 03/20] drop `(0)` footnote from `%t` docs, reflecting support; add support note --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 39a7a1530a95cc..a73419d801ff83 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2584,7 +2584,7 @@ requires, and these work on all supported platforms. | ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(4), | | | decimal number. | | \(9) | +-----------+--------------------------------+------------------------+-------+ -| ``%t`` | The tab character | ``\t`` | \(0) | +| ``%t`` | The tab character | ``\t`` | | | | (``'\t'``). | | | +-----------+--------------------------------+------------------------+-------+ | ``%T`` | ISO 8601 time format, | 10:01:59 | | From 669870a6c7b8a37d4afc953c7760115be7f63186 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 03:43:09 +0000 Subject: [PATCH 04/20] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst diff --git a/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst b/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst new file mode 100644 index 00000000000000..f4ffd5187431a8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst @@ -0,0 +1 @@ +Add ``'%t'`` support to :meth:`~datetime.datetime.strptime`. From d77ebf761b5947eadb08ab4312c0e7e4d1dda37b Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Mon, 16 Feb 2026 20:45:28 -0700 Subject: [PATCH 05/20] add support note --- Doc/library/datetime.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index a73419d801ff83..db836032b05114 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2676,7 +2676,8 @@ differences between platforms in handling of unsupported format specifiers. ``%:z`` was added for :meth:`~.datetime.strftime`. .. versionadded:: 3.15 - ``%:z``, ``%F``, and ``%D`` were added for :meth:`~.datetime.strptime`. + ``%:z``, ``%F``, ``%D``, and ``%t`` were added for + :meth:`~.datetime.strptime`. Technical Detail ^^^^^^^^^^^^^^^^ From fcc03cf95b4219712fac65a0b7e1806e1f4de73f Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Fri, 20 Feb 2026 22:32:32 -0700 Subject: [PATCH 06/20] modify %t -> more general r'\s+' from '\t' to meet C99 --- Lib/_strptime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py index b734954ab46bda..f41177213f7666 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -382,7 +382,7 @@ def __init__(self, locale_time=None): 'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone for tz in tz_names), 'Z'), - 't': '\t', + 't': r'\s+', '%': '%' } if self.locale_time.LC_alt_digits is None: From 519315721587dac1adc482785d0ea992061a19d3 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Fri, 20 Feb 2026 23:00:35 -0700 Subject: [PATCH 07/20] use theclass() and test '\s+' functionality, as requested --- Lib/test/datetimetester.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index ddb82da01e0200..8d8b971191d19a 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -2208,10 +2208,13 @@ def test_strptime_D_format(self): ) def test_strptime_t_format(self): - test_date = "2026\t02\t16" + test_year,test_month,test_day = 2026,2,20 self.assertEqual( - self.theclass.strptime(test_date, "%Y%t%m%t%d"), - self.theclass.strptime(test_date, "%Y\t%m\t%d") + self.theclass.strptime( + f'{test_year} \r {test_month}\t \n{test_day}', + "%Y%t%m%t%d" + ), + self.theclass(test_year,test_month,test_day) ) From edfed51a3d07899f7e01e2a27d238887f23e52c7 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Fri, 20 Feb 2026 23:38:13 -0700 Subject: [PATCH 08/20] test '\s+' functionality, as requested --- Lib/test/test_strptime.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index cad3bd928b7ad9..b8c33cb5c388de 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -671,10 +671,16 @@ def test_strptime_D_format(self): ) def test_strptime_t_format(self): - test_date = "2026\t02\t16" + test_year,test_month,test_day = 2026,2,20 self.assertEqual( - time.strptime(test_date, "%Y%t%m%t%d"), - time.strptime(test_date, "%Y\t%m\t%d") + time.strptime( + f'{test_year} \r {test_month}\t \n{test_day}', + "%Y%t%m%t%d" + ), + time.strptime( + f'{test_year}-{test_month}-{test_day}', + "%Y-%m-%d" + ) ) class Strptime12AMPMTests(unittest.TestCase): From 16195db0634753cf4edce518c49409d03aa96b15 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Fri, 20 Feb 2026 23:39:59 -0700 Subject: [PATCH 09/20] alphabetize 3.15 patch notes --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index db836032b05114..f15d7afa32d30d 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2676,7 +2676,7 @@ differences between platforms in handling of unsupported format specifiers. ``%:z`` was added for :meth:`~.datetime.strftime`. .. versionadded:: 3.15 - ``%:z``, ``%F``, ``%D``, and ``%t`` were added for + ``%D``, ``%F``, ``%t``, and ``:%z`` were added for :meth:`~.datetime.strptime`. Technical Detail From 73019625213c39fb6a868ce72a81db4119742cde Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sat, 21 Feb 2026 00:32:18 -0700 Subject: [PATCH 10/20] update docs to reflect powerful %t strptime functionality --- Doc/library/datetime.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index f15d7afa32d30d..45f5f00f7978f4 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2584,8 +2584,11 @@ requires, and these work on all supported platforms. | ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(4), | | | decimal number. | | \(9) | +-----------+--------------------------------+------------------------+-------+ -| ``%t`` | The tab character | ``\t`` | | -| | (``'\t'``). | | | +| ``%t`` | The tab character, ``'\t'``, | ``\t`` | \(11) | +| | for ``strftime``, else | | | +| | for ``strptime``, any | | | +| | blank-space character(s), | | | +| | i.e., ``'\s+'``. | | | +-----------+--------------------------------+------------------------+-------+ | ``%T`` | ISO 8601 time format, | 10:01:59 | | | | equivalent to ``%H:%M:%S``. | | | @@ -2881,6 +2884,12 @@ Notes: :exc:`DeprecationWarning`. In 3.15 or later we may change this into an error or change the default year to a leap year. See :gh:`70647`. +(11) + See `The Open Group Base Specifications Issue 8 IEEE Std 1003.1-2024 + documentation for strptime + `_ + for details on the :meth: `~.datetime.strptime` invocation. + .. rubric:: Footnotes .. [#] If, that is, we ignore the effects of Relativity From b753ea6b372de3761ab306735e68ba4073c47600 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Sun, 22 Feb 2026 15:54:13 -0700 Subject: [PATCH 11/20] simplify docs, as requested --- Doc/library/datetime.rst | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 45f5f00f7978f4..423a70f4da10c1 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2584,11 +2584,9 @@ requires, and these work on all supported platforms. | ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(4), | | | decimal number. | | \(9) | +-----------+--------------------------------+------------------------+-------+ -| ``%t`` | The tab character, ``'\t'``, | ``\t`` | \(11) | -| | for ``strftime``, else | | | -| | for ``strptime``, any | | | -| | blank-space character(s), | | | -| | i.e., ``'\s+'``. | | | +| ``%t`` | The tab character (``'\t'``). | ``\t`` | | +| | For :meth:`!strptime`, | | | +| | arbitrary whitespace. | | | +-----------+--------------------------------+------------------------+-------+ | ``%T`` | ISO 8601 time format, | 10:01:59 | | | | equivalent to ``%H:%M:%S``. | | | @@ -2884,12 +2882,6 @@ Notes: :exc:`DeprecationWarning`. In 3.15 or later we may change this into an error or change the default year to a leap year. See :gh:`70647`. -(11) - See `The Open Group Base Specifications Issue 8 IEEE Std 1003.1-2024 - documentation for strptime - `_ - for details on the :meth: `~.datetime.strptime` invocation. - .. rubric:: Footnotes .. [#] If, that is, we ignore the effects of Relativity From 9b29dbbd4be5166052e5349c80f2cfaa19dc5c8b Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:25:46 -0700 Subject: [PATCH 12/20] Update Doc/library/datetime.rst typo fix Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 423a70f4da10c1..272f03d399867a 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2677,7 +2677,7 @@ differences between platforms in handling of unsupported format specifiers. ``%:z`` was added for :meth:`~.datetime.strftime`. .. versionadded:: 3.15 - ``%D``, ``%F``, ``%t``, and ``:%z`` were added for + ``%D``, ``%F``, ``%t``, and ``%:z`` were added for :meth:`~.datetime.strptime`. Technical Detail From d199d0b2ed18b1e9dd44313574bd3af063c871f5 Mon Sep 17 00:00:00 2001 From: "Jason Yalim, PhD" <4813268+jyalim@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:26:12 -0700 Subject: [PATCH 13/20] Update Lib/test/datetimetester.py remove trailing whitespace Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Lib/test/datetimetester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 8d8b971191d19a..aa71bd01e84073 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -2211,7 +2211,7 @@ def test_strptime_t_format(self): test_year,test_month,test_day = 2026,2,20 self.assertEqual( self.theclass.strptime( - f'{test_year} \r {test_month}\t \n{test_day}', + f'{test_year} \r {test_month}\t \n{test_day}', "%Y%t%m%t%d" ), self.theclass(test_year,test_month,test_day) From dac5692f9a2e6809691a38faac378176ea2ea08c Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 22:54:46 -0700 Subject: [PATCH 14/20] correctly capture '' with '\s*' instead of '\s+' --- Lib/_strptime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/_strptime.py b/Lib/_strptime.py index f41177213f7666..fb8a32781490a9 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -382,7 +382,7 @@ def __init__(self, locale_time=None): 'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone for tz in tz_names), 'Z'), - 't': r'\s+', + 't': r'\s*', '%': '%' } if self.locale_time.LC_alt_digits is None: From e9927fb2e14d3d70f4987a92b7ca1df5d0394799 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 22:58:54 -0700 Subject: [PATCH 15/20] update tests with subtests for all whitespace chars covered by '\s' --- Lib/test/datetimetester.py | 17 ++++++++++------- Lib/test/test_strptime.py | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index aa71bd01e84073..c4230dedb365fa 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -2209,13 +2209,16 @@ def test_strptime_D_format(self): def test_strptime_t_format(self): test_year,test_month,test_day = 2026,2,20 - self.assertEqual( - self.theclass.strptime( - f'{test_year} \r {test_month}\t \n{test_day}', - "%Y%t%m%t%d" - ), - self.theclass(test_year,test_month,test_day) - ) + whitespaces = ('',' ','\t','\r','\v','\n','\f') + for ws in (*whitespaces,''.join(whitespaces)): + with self.subTest(whitespace=ws): + self.assertEqual( + self.theclass.strptime( + f'{test_year:04d}{ws}{test_month:02d}{ws}{test_day:02d}', + "%Y%t%m%t%d" + ), + self.theclass(test_year,test_month,test_day) + ) ############################################################################# diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index b8c33cb5c388de..2ea5b5582cceaa 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -672,16 +672,19 @@ def test_strptime_D_format(self): def test_strptime_t_format(self): test_year,test_month,test_day = 2026,2,20 - self.assertEqual( - time.strptime( - f'{test_year} \r {test_month}\t \n{test_day}', - "%Y%t%m%t%d" - ), - time.strptime( - f'{test_year}-{test_month}-{test_day}', - "%Y-%m-%d" - ) - ) + whitespaces = ('',' ','\t','\r','\v','\n','\f') + for ws in (*whitespaces,''.join(whitespaces)): + with self.subTest(whitespace=ws): + self.assertEqual( + time.strptime( + f'{test_year:04d}{ws}{test_month:02d}{ws}{test_day:02d}', + "%Y%t%m%t%d" + ), + time.strptime( + f'{test_year:04d}-{test_month:02d}-{test_day:02d}', + "%Y-%m-%d" + ) + ) class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" From c674612f13375762887e2accc6e6beaaea8889f3 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 23:04:56 -0700 Subject: [PATCH 16/20] init `%n` support for `strptime` --- Lib/_strptime.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/_strptime.py b/Lib/_strptime.py index fb8a32781490a9..27c6ef849d26e6 100644 --- a/Lib/_strptime.py +++ b/Lib/_strptime.py @@ -382,6 +382,7 @@ def __init__(self, locale_time=None): 'Z': self.__seqToRE((tz for tz_names in self.locale_time.timezone for tz in tz_names), 'Z'), + 'n': r'\s*', 't': r'\s*', '%': '%' } From 3a262055b3133b10aa132f9a22eb340acb35596d Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 23:05:27 -0700 Subject: [PATCH 17/20] init tests for `%n` support in `strptime` --- Lib/test/datetimetester.py | 13 +++++++++++++ Lib/test/test_strptime.py | 16 ++++++++++++++++ Lib/test/test_time.py | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index c4230dedb365fa..9b38aab75f7908 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -2220,6 +2220,19 @@ def test_strptime_t_format(self): self.theclass(test_year,test_month,test_day) ) + def test_strptime_n_format(self): + test_year,test_month,test_day = 2026,2,25 + whitespaces = ('',' ','\t','\r','\v','\n','\f') + for ws in (*whitespaces,''.join(whitespaces)): + with self.subTest(whitespace=ws): + self.assertEqual( + self.theclass.strptime( + f'{test_year:04d}{ws}{test_month:02d}{ws}{test_day:02d}', + "%Y%n%m%n%d" + ), + self.theclass(test_year,test_month,test_day) + ) + ############################################################################# # datetime tests diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 2ea5b5582cceaa..10efbd0bbcec3c 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -686,6 +686,22 @@ def test_strptime_t_format(self): ) ) + def test_strptime_n_format(self): + test_year,test_month,test_day = 2026,2,20 + whitespaces = ('',' ','\t','\r','\v','\n','\f') + for ws in (*whitespaces,''.join(whitespaces)): + with self.subTest(whitespace=ws): + self.assertEqual( + time.strptime( + f'{test_year:04d}{ws}{test_month:02d}{ws}{test_day:02d}', + "%Y%n%m%n%d" + ), + time.strptime( + f'{test_year:04d}-{test_month:02d}-{test_day:02d}', + "%Y-%m-%d" + ) + ) + class Strptime12AMPMTests(unittest.TestCase): """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index a96808ea182f8c..be8f6b057654c2 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -359,7 +359,7 @@ def test_strptime(self): # raising an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'D', 'F', 'H', 'I', - 'j', 'm', 'M', 'p', 'S', 't', 'T', + 'j', 'm', 'M', 'n', 'p', 'S', 't', 'T', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): format = '%' + directive if directive == 'd': From f709b80840f84d771e1159f6197b5bbae202e953 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 23:10:31 -0700 Subject: [PATCH 18/20] update docs for `%n` support; drop (0) in footnote --- Doc/library/datetime.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 272f03d399867a..0bfddde21ece1d 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -2570,8 +2570,10 @@ requires, and these work on all supported platforms. | ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | \(9) | | | decimal number. | | | +-----------+--------------------------------+------------------------+-------+ -| ``%n`` | The newline character | ``\n`` | \(0) | -| | (``'\n'``). | | | +| ``%n`` | The newline character | ``\n`` | | +| | (``'\n'``). For | | | +| | :meth:`!strptime`, arbitrary | | | +| | whitespace. | | | +-----------+--------------------------------+------------------------+-------+ | ``%p`` | Locale's equivalent of either || AM, PM (en_US); | \(1), | | | AM or PM. || am, pm (de_DE) | \(3) | @@ -2677,7 +2679,7 @@ differences between platforms in handling of unsupported format specifiers. ``%:z`` was added for :meth:`~.datetime.strftime`. .. versionadded:: 3.15 - ``%D``, ``%F``, ``%t``, and ``%:z`` were added for + ``%D``, ``%F``, ``%n``, ``%t``, and ``%:z`` were added for :meth:`~.datetime.strptime`. Technical Detail From 924b7cff2a6f57d6eff6f85d31c9c9e2788fff69 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 23:14:13 -0700 Subject: [PATCH 19/20] update NEWS to include `%n` --- .../next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst b/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst index f4ffd5187431a8..a47652feab19d3 100644 --- a/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst +++ b/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst @@ -1 +1 @@ -Add ``'%t'`` support to :meth:`~datetime.datetime.strptime`. +Add ``'%t'`` and ``'%n'`` support to :meth:`~datetime.datetime.strptime`. From ed87c7d88ee25c796acdd8c4a42b69be2b037791 Mon Sep 17 00:00:00 2001 From: Jason Yalim Date: Wed, 25 Feb 2026 23:15:11 -0700 Subject: [PATCH 20/20] %n before %t to match general style --- .../next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst b/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst index a47652feab19d3..dbdb42cb468083 100644 --- a/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst +++ b/Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.twmcM_.rst @@ -1 +1 @@ -Add ``'%t'`` and ``'%n'`` support to :meth:`~datetime.datetime.strptime`. +Add ``'%n'`` and ``'%t'`` support to :meth:`~datetime.datetime.strptime`.