You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mattip opened this issue
Sep 24, 2023
· 4 comments
Labels
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesextension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
import_datetime, _pydatetime_datetime.date(1, 1, 50)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>ValueError: dayisoutofrangeformonth```
_pydatetime.date(1, 1, 50)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/usr/lib/python3.12/_pydatetime.py", line960, in__new__year, month, day=_check_date_fields(year, month, day)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.12/_pydatetime.py", line535, in_check_date_fieldsraiseValueError('day must be in 1..%d'%dim, day)
ValueError: ('day must be in 1..31', 50)
The error message differs between the two implementations of datetime. This came up when testing PyPy, which uses the pure-python datetime implementation. xref conda-forge/rtoml-feedstock#1 (comment)
Ok, I will leave error message as in the c implementation
Firstly, it is better to output a string (not tuple), and in the python implementation, the second value in tuple is redundant.
Secondly, it seems to me that it is the main implementation.
I also add more inconsistency in the error messages that I found in the code
1. Errors about date and time have inconsistent messages, for example problem with year field may raise next errors:
ValueError: ('year must be in 1..9999', {year})
ValueError: Yearisoutofrange: {year}
ValueError: year {year} isoutofrangeValueError: Year {year} isoutofrange
We need to make same message template for the fields year, month, day, hour, minute, second, microsecond and fold.
2. Method date.fromisocalendar may raise next errors depends on implementation:
3. Error with offset argument in timezone may raise next errors:
ValueError: offsetmustbeatimedeltastrictlybetween-timedelta(hours=24) andtimedelta(hours=24), notdatetime.timedelta(days=21). # with dotValueError: offsetmustbeatimedeltastrictlybetween-timedelta(hours=24) andtimedelta(hours=24), notdatetime.timedelta(days=21) # without dotValueError: offsetmustbeatimedeltastrictlybetween-timedelta(hours=24) andtimedelta(hours=24).
ValueError: {name}()={offset}, mustbeatimedeltastrictlybetween-timedelta(hours=24) andtimedelta(hours=24)
4. Errors about type of arugment
for example if i call _pydatetime.datetime() and _datetime.datetime() with tz i get:
TypeError: tzinfoargumentmustbeNoneorofatzinfosubclass# in _pydatetimeTypeError: tzinfoargumentmustbeNoneorofatzinfosubclass, nottype'int'# in _datetime
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesextension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
Bug report
Bug description:
The error message differs between the two implementations of datetime. This came up when testing PyPy, which uses the pure-python datetime implementation. xref conda-forge/rtoml-feedstock#1 (comment)
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
_datetime
anddatetime
error messages #127345The text was updated successfully, but these errors were encountered: