-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-109798: Normalize _datetime
and datetime
error messages
#127345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
764eb1b
2bf419f
4363e9e
9da0dfc
179423d
f691251
d8973cf
5eea62f
79543cc
d174497
498c4ba
216d0fe
c409fec
3f454f6
a2b8f7a
209c338
0777aa5
4d31d33
f05ebba
f840105
61c95a5
2ab77b3
b1e272a
7a35bd4
cfd18cb
2827514
cd3bdc1
9915dfe
1da5a3a
610f067
410e0ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2423,7 +2423,7 @@ def __new__(cls, offset, name=_Omitted): | |
if not cls._minoffset <= offset <= cls._maxoffset: | ||
raise ValueError("offset must be a timedelta " | ||
"strictly between -timedelta(hours=24) and " | ||
f"timedelta(hours=24), not {offset.__repr__()}") | ||
f"timedelta(hours=24), not {offset!r}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not going to be a great user experience here because of how bad the >>> print(f"{timedelta(hours=-25)!r}")
datetime.timedelta(days=-2, seconds=82800) Maybe it will be clearer if we do it this way: if offset < timedelta(0):
offset_str = f"-{-offset)}"
else:
offset_str = str(offset) That will print stuff like Probably a more elaborate timedelta formatter would be better, since we basically always want this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return cls._create(offset, name) | ||
|
||
def __init_subclass__(cls): | ||
|
Uh oh!
There was an error while loading. Please reload this page.