Visitar URL original
gh-70647: Better promote how to safely parse yearless dates in datetime. by gpshead 路 Pull Request #116179 路 python/cpython 路 GitHub
Skip to content
Merged
Changes from 1 commit
Commits
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
ignore the warning in the doctest
  • Loading branch information
gpshead committed Mar 21, 2025
commit 8c6fd9b0b5b51146d04c0a0cdbe978fcbaa10fc4
6 changes: 5 additions & 1 deletion Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2631,8 +2631,12 @@ will be pulled from the default value.
.. doctest::

>>> from datetime import datetime
>>> import warnings
>>> value = "2/29"
>>> datetime.strptime(value, "%m/%d")
>>> with warnings.catch_warnings():
Comment thread
gpshead marked this conversation as resolved.
Outdated
... warnings.simplefilter("ignore")
... datetime.strptime(value, "%m/%d")
...
Traceback (most recent call last):
...
ValueError: day 29 must be in range 1..28 for month 2 in year 1900
Expand Down