FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-70647: Add detail to error message when parsing a bad day of month. by gpshead · Pull Request #116184 · python/cpython · GitHub

/ cpython Public

gh-70647: Add detail to error message when parsing a bad day of month. - #116184

Closed
gpshead wants to merge 1 commit into
python:mainfrom
gpshead:datetime/day_of_month/errmsg
Closed

gh-70647: Add detail to error message when parsing a bad day of month.#116184
gpshead wants to merge 1 commit into
python:mainfrom
gpshead:datetime/day_of_month/errmsg

Conversation

gpshead commented Mar 1, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

The presence of the values in the error message gives a stronger hint as to what went wrong.

>>> datetime.strptime("2.29", "%m.%d")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    datetime.strptime("2.29", "%m.%d")
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File ".../Lib/_strptime.py", line 565, in _strptime_datetime
    return cls(*args)
           ~~~^^^^^^^
ValueError: day 29 is out of range for month 2 in year 1900

… month.

The presence of the values in the error message gives a stronger hint as
to what went wrong.

```
>>> datetime.strptime("2.29", "%m.%d")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    datetime.strptime("2.29", "%m.%d")
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File ".../Lib/_strptime.py", line 565, in _strptime_datetime
    return cls(*args)
           ~~~^^^^^^^
ValueError: day 29 is out of range for month 2 in year 1900
```

pitrou commented Mar 1, 2024

Copy link
Copy Markdown
Member

+1 on the principle, but ideally there would be a test for this.

gpshead commented Mar 21, 2025

Copy link
Copy Markdown
Member Author

closing in favor of #131335

gpshead closed this Mar 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL