summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-18 12:42:05 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-09-18 12:42:05 (GMT)
commit511491ade0bb77febb176bc75f049797f0c71ed0 (patch)
tree1981db4c2c00eef86f32c03589174f98e46df857 /Misc
parente3bcbd2bbade81a3591d69f607e1722c6016a489 (diff)
downloadcpython-511491ade0bb77febb176bc75f049797f0c71ed0.zip
cpython-511491ade0bb77febb176bc75f049797f0c71ed0.tar.gz
cpython-511491ade0bb77febb176bc75f049797f0c71ed0.tar.bz2
Issue #23517: Fix rounding in fromtimestamp() and utcfromtimestamp() methods
of datetime.datetime: microseconds are now rounded to nearest with ties going to nearest even integer (ROUND_HALF_EVEN), instead of being rounding towards zero (ROUND_DOWN). It's important that these methods use the same rounding mode than datetime.timedelta to keep the property: (datetime(1970,1,1) + timedelta(seconds=t)) == datetime.utcfromtimestamp(t) It also the rounding mode used by round(float) for example. Add more unit tests on the rounding mode in test_datetime.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS8
1 files changed, 8 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index e9fe6c7..d570bd4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,6 +81,14 @@ Core and Builtins
Library
-------
+- Issue #23517: Fix rounding in fromtimestamp() and utcfromtimestamp() methods
+ of datetime.datetime: microseconds are now rounded to nearest with ties
+ going to nearest even integer (ROUND_HALF_EVEN), instead of being rounding
+ towards zero (ROUND_DOWN). It's important that these methods use the same
+ rounding mode than datetime.timedelta to keep the property:
+ (datetime(1970,1,1) + timedelta(seconds=t)) == datetime.utcfromtimestamp(t).
+ It also the rounding mode used by round(float) for example.
+
- Issue #24684: socket.socket.getaddrinfo() now calls
PyUnicode_AsEncodedString() instead of calling the encode() method of the
host, to handle correctly custom string with an encode() method which doesn't