Uh oh!
There was an error while loading. Please reload this page.
gh-140715: Add %t and %n format codes support to strptime() - #144896
Conversation
StanFromIreland
left a comment
There was a problem hiding this comment.
This is quite an odd case, as per the standard for strftime, it is a \t character, however, for strptime():
And, more straightforward:
Considering that this is the wide-spread behaviour, it should instead be r'\s+' for %n/%t (with additional tests), and add a note to the doc.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jyalim
commented
Feb 21, 2026
Thanks, this was a great catch that adds some power to |
Uh oh!
There was an error while loading. Please reload this page.
jyalim
commented
Feb 22, 2026
Thank you, the documentation changes were implemented. |
StanFromIreland
left a comment
There was a problem hiding this comment.
We could also do \n now, since it is equivalent. (re-use the tests please)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
typo fix Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
remove trailing whitespace Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
jyalim
commented
Feb 26, 2026
Thanks! All the requested changes were implemented. The title and description of this PR were also updated to include |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jyalim
commented
Feb 28, 2026
Thank you, the tests have been merged and all requested changes have been implemented. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
clarify "arbitrary" with "zero or more" Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
clarify "arbitrary" with "zero or more" Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
…wmcM_.rst Drop quotes around format directives Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
StanFromIreland
commented
Mar 1, 2026
Something broke with the CI, I'll try updating the branch. |
jyalim
commented
Mar 1, 2026
Thanks! Changes have been made. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| def test_strptime_n_and_t_format(self): | ||
| whitespaces = ('', ' ', '\t', '\r', '\v', '\n', '\f') | ||
| for fd in ('n', 't'): |
There was a problem hiding this comment.
Would it make sense to also test '%n%t' and the non-empty whitespaces as part of the pattern?
There was a problem hiding this comment.
Would it make sense to add whitespace to the table in the docs? (It already worked before, but AFAIK wasn't documented/tested.)
There was a problem hiding this comment.
Commit d6ca685 added '%n%t' and '%t%n'.
The final test for each whitespace format directive is ' \t\r\v\n\f', due to the ''.join(whitespaces) argument in the loop. Did you have another non-empty whitespace pattern in mind?
I'm all for improved documentation, could you clarify what you are envisioning? The whitespace format directives (%n and %t) are specified in the format directive table.
There was a problem hiding this comment.
(By pattern I meant fd; thanks for doing that change!)
In docs, I meant adding entries for space and tab, in addition to the percent directives, to document that strptime “collapses” runs of whitespace kand %t/%n.
PEP 8 fix on existing code Co-authored-by: Petr Viktorin <encukou@gmail.com>
PEP 8 comma for exploded function arguments Co-authored-by: Petr Viktorin <encukou@gmail.com>
…lso add PEP 8 trailing commas to all exploded function arguments
encukou
commented
Mar 13, 2026
The remaining doc update can be done in a separate PR. |
Uh oh!
There was an error while loading. Please reload this page.
…thonGH-144896) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Incrementally builds C99+ datetime support with addition of
%tand%nwith two lines of code. Also adds tests and updates documentation.Continued effort from PR: #140647 , #144819.
Documentation drops (0) footnote.
Passed all tests.
Passed patchcheck.
Issue: #140715
str*timeto C11 format codes #140715Note, this PR originally only was for
%t;%nwas added 2026-02-25.📚 Documentation preview 📚: https://cpython-previews--144896.org.readthedocs.build/