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
donBarbos opened this issue
Nov 25, 2024
· 1 comment
Labels
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
As far as I understand, the documentation says that Z char should mean that tzinfo is timezone.utc, so there cannot be any time zone fields after it.
Based on this, _pydatetime implementation is incorrect, right?
2. Miss the wrong millisecond separator in _datetime
In _pydatetime the separator for milliseconds must be either a period . or a comma ,.
Should we allow colon : as millisecond separator?
>>>import_datetime, _pydatetime>>>_datetime.datetime.fromisoformat('2020-01-01T00:00:01:1')
datetime.datetime(2020, 1, 1, 0, 0, 1, 100000)
>>>_pydatetime.datetime.fromisoformat('2020-01-01T00:00:01:1')
Traceback (mostrecentcalllast):
File"<python-input-119>", line1, in<module>_pydatetime.datetime.fromisoformat('2020-01-01T00:00:01:1')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^File".../cpython/Lib/_pydatetime.py", line1969, infromisoformat"Return local time tuple compatible with time.localtime()."^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^dst=self.dst()
^^^^^^^^^^^^^^^^ValueError: Invalidisoformatstring: '2020-01-01T00:00:01:1'
3. The first errors caught can be different
If these errors occur separately, then both implementations are able to detect them, but when there are several problems, the methods may behave differently. In this case _pydatetime first detected an error due to the separator, and _datetime first detected an error in exceeding the limits.
picnixz
changed the title
Inconsistent behavior of fromisoformat methods in datetime module implementations
gh-109798: Inconsistent behavior of fromisoformat methods in datetime module implementations
Nov 27, 2024
Ah crap I thought this one was a PR. Reverting the title.
picnixz
changed the title
gh-109798: Inconsistent behavior of fromisoformat methods in datetime module implementations
Inconsistent behavior of fromisoformat methods in datetime module implementations
Nov 27, 2024
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
Bug report
Bug description:
1. Incorrect timezone validation in
_pydatetime
As far as I understand, the documentation says that
Z
char should mean thattzinfo
istimezone.utc
, so there cannot be any time zone fields after it.Based on this,
_pydatetime
implementation is incorrect, right?2. Miss the wrong millisecond separator in
_datetime
In
_pydatetime
the separator for milliseconds must be either a period.
or a comma,
.Should we allow colon
:
as millisecond separator?3. The first errors caught can be different
If these errors occur separately, then both implementations are able to detect them, but when there are several problems, the methods may behave differently. In this case
_pydatetime
first detected an error due to the separator, and_datetime
first detected an error in exceeding the limits.Also also an issue has already been created about the fact that some errors have different output, here:
I'll send a PR.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered: