[issue23607] Inconsistency in datetime.utcfromtimestamp(Decimal)

Paul Ganssle report at bugs.python.org
Wed Feb 27 12:10:29 EST 2019


Paul Ganssle <p.ganssle at gmail.com> added the comment:

Oh actually that's my mistake. I can't reproduce the failure in the constructor in the Python version of the module, and also it seems to be fixed in the pure Python version as of at least 3.6:

Python 3.6.7 (default, Oct 25 2018, 16:11:17) 
[GCC 8.2.1 20180831] on linux
>>> import sys
>>> sys.modules['_datetime'] = None
>>> from decimal import Decimal as D
>>> from datetime import datetime
>>> datetime.utcfromtimestamp(D(123456.12345))
datetime.datetime(1970, 1, 2, 10, 17, 36, 123450)

But the truncation behavior is still present in the C version as of Python 3.8.0a1+:

Python 3.8.0a1+ (heads/master:3766f18, Feb 11 2019, 12:52:31) 
[GCC 8.2.1 20181127] on linux
>>> from datetime import datetime
>>> from decimal import Decimal as D
>>> datetime.utcfromtimestamp(D(123456.12345))
datetime.datetime(1970, 1, 2, 10, 17, 36)


I still think we need a test for the constructor behavior, but I'm going to remove "easy", since we still need to fix truncation in the C version.

----------
keywords:  -easy

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue23607>
_______________________________________


More information about the Python-bugs-list mailing list