STINNER Victor added the comment:

Ok, I fixed the issue in Python 3.6. Example with the initial message:

$ python2.7 -c 'import datetime; 
print(datetime.datetime.utcfromtimestamp(1424817268.274).microsecond); 
print(datetime.datetime.utcfromtimestamp(-1424817268.274).microsecond)'
274000
726000

$ python3.6 -c 'import datetime; 
print(datetime.datetime.utcfromtimestamp(1424817268.274).microsecond); 
print(datetime.datetime.utcfromtimestamp(-1424817268.274).microsecond)'
274000
726000

I wrote:
"On Python < 3.3, datetime.datetime.fromtimestamp(float) doesn't use exactly 
ROUND_HALF_EVEN, but it looks more to "round half away from zero" (the decimal 
module doesn't seem to support this exact rounding method)."

I was wrong: it's decimal.ROUND_HALF_UP in fact.

I will backport the change to Python 3.4 and 3.5. Since this issue was defined 
as a bugfix, it should be fixed in Python 3.5.1 (too late for 3.5.0).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23517>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to