Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
43c8345
add `%t` C99 token to strptime
jyalim Feb 17, 2026
d838236
init passing tests
jyalim Feb 17, 2026
a31ad12
drop `(0)` footnote from `%t` docs, reflecting support; add support note
jyalim Feb 17, 2026
669870a
📜🤖 Added by blurb_it.
blurb-it[bot] Feb 17, 2026
d77ebf7
add support note
jyalim Feb 17, 2026
fcc03cf
modify %t -> more general r'\s+' from '\t' to meet C99
jyalim Feb 21, 2026
5193157
use theclass() and test '\s+' functionality, as requested
jyalim Feb 21, 2026
edfed51
test '\s+' functionality, as requested
jyalim Feb 21, 2026
16195db
alphabetize 3.15 patch notes
jyalim Feb 21, 2026
7301962
update docs to reflect powerful %t strptime functionality
jyalim Feb 21, 2026
b753ea6
simplify docs, as requested
jyalim Feb 22, 2026
9b29dbb
Update Doc/library/datetime.rst
jyalim Feb 26, 2026
d199d0b
Update Lib/test/datetimetester.py
jyalim Feb 26, 2026
dac5692
correctly capture '' with '\s*' instead of '\s+'
jyalim Feb 26, 2026
e9927fb
update tests with subtests for all whitespace chars covered by '\s'
jyalim Feb 26, 2026
c674612
init `%n` support for `strptime`
jyalim Feb 26, 2026
3a26205
init tests for `%n` support in `strptime`
jyalim Feb 26, 2026
f709b80
update docs for `%n` support; drop (0) in footnote
jyalim Feb 26, 2026
924b7cf
update NEWS to include `%n`
jyalim Feb 26, 2026
ed87c7d
%n before %t to match general style
jyalim Feb 26, 2026
9541826
merge tests; fix formatting
jyalim Feb 28, 2026
2f91a57
directive
jyalim Feb 28, 2026
608c638
Update Doc/library/datetime.rst
jyalim Mar 1, 2026
4a4d722
Update Doc/library/datetime.rst
jyalim Mar 1, 2026
4080b03
Update Misc/NEWS.d/next/Library/2026-02-17-03-43-07.gh-issue-140715.t…
jyalim Mar 1, 2026
bbe7d2e
Merge branch 'main' into fix-issue-140715--t
StanFromIreland Mar 1, 2026
ab9d41a
replace vars with literals, as requested
jyalim Mar 1, 2026
4a312ab
Apply suggestion from @StanFromIreland
StanFromIreland Mar 2, 2026
4c31a92
Update Lib/_strptime.py
jyalim Mar 3, 2026
3d7c3c7
Update Lib/test/datetimetester.py
jyalim Mar 3, 2026
d6ca685
refactor tests to include joint directive tests, `%n%t` and `%t%n`; a…
jyalim Mar 3, 2026
4e366cb
bump test date by two days to distinguish from month (02) and default…
jyalim Mar 3, 2026
9f5a37e
reorder helper tuples to reflect loop order
jyalim Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace vars with literals, as requested
  • Loading branch information
jyalim committed Mar 1, 2026
commit ab9d41ac3151d945268cb9af71d6ed1ac9d2bcc8
5 changes: 2 additions & 3 deletions Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -2208,17 +2208,16 @@ def test_strptime_D_format(self):
)

def test_strptime_n_and_t_format(self):
year, month, day = 2026, 2, 20
whitespaces = ('', ' ', '\t', '\r', '\v', '\n', '\f')
for fd in ('n', 't'):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also test '%n%t' and the non-empty whitespaces as part of the pattern?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add whitespace to the table in the docs? (It already worked before, but AFAIK wasn't documented/tested.)

Copy link
Copy Markdown
Contributor Author

@jyalim jyalim Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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.

for ws in (*whitespaces, ''.join(whitespaces)):
with self.subTest(format_directive=fd, whitespace=ws):
self.assertEqual(
self.theclass.strptime(
f"{year:04d}{ws}{month:02d}{ws}{day:02d}",
f"2026{ws}02{ws}01",
Comment thread
jyalim marked this conversation as resolved.
Outdated
f"%Y%{fd}%m%{fd}%d"
Comment thread
jyalim marked this conversation as resolved.
Outdated
),
self.theclass(year, month, day)
self.theclass(2026, 2, 1)
Comment thread
jyalim marked this conversation as resolved.
Outdated
)

Comment thread
StanFromIreland marked this conversation as resolved.
#############################################################################
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_strptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,18 +671,17 @@ def test_strptime_D_format(self):
)

def test_strptime_n_and_t_format(self):
year, month, day = 2026, 2, 20
whitespaces = ('', ' ', '\t', '\r', '\v', '\n', '\f')
for fd in ('n', 't'):
for ws in (*whitespaces, ''.join(whitespaces)):
with self.subTest(format_directive=fd, whitespace=ws):
self.assertEqual(
time.strptime(
f"{year:04d}{ws}{month:02d}{ws}{day:02d}",
f"2026{ws}02{ws}01",
f"%Y%{fd}%m%{fd}%d"
),
time.strptime(
f'{year:04d}-{month:02d}-{day:02d}',
f'2026-02-01',
"%Y-%m-%d"
)
)
Expand Down
Loading