diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2016-03-25 19:46:55 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2016-03-25 19:46:55 (GMT) |
commit | 16b698b095bfc6cd37b66a58536fb11a6884b557 (patch) | |
tree | b2eecef447ab5e11e5be1678e9f8b504c2e1c99d | |
parent | d7ac00e6209ae29fbd4c9dd71885c32ad4c7340e (diff) | |
parent | 1dcf4f9ee5b60f23291a377353b3dceca7cc9dc9 (diff) | |
download | cpython-16b698b095bfc6cd37b66a58536fb11a6884b557.zip cpython-16b698b095bfc6cd37b66a58536fb11a6884b557.tar.gz cpython-16b698b095bfc6cd37b66a58536fb11a6884b557.tar.bz2 |
merge
-rw-r--r-- | Lib/test/datetimetester.py | 8 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/_datetimemodule.c | 7 |
3 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 4f20ffd..1f992f9 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -3463,6 +3463,14 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase): self.assertEqual(dt, local) self.assertEqual(local.strftime("%z %Z"), "-0400 EDT") + @support.run_with_tz('EST+05EDT,M3.2.0,M11.1.0') + def test_astimezone_default_near_fold(self): + # Issue #26616. + u = datetime(2015, 11, 1, 5, tzinfo=timezone.utc) + t = u.astimezone() + s = t.astimezone() + self.assertEqual(t.tzinfo, s.tzinfo) + def test_aware_subtract(self): cls = self.theclass @@ -232,6 +232,8 @@ Core and Builtins Library ------- +- Issue #26616: Fixed a bug in datetime.astimezone() method. + - Issue #26637: The :mod:`importlib` module now emits an :exc:`ImportError` rather than a :exc:`TypeError` if :func:`__import__` is tried during the Python shutdown process but :data:`sys.path` is already cleared (set to diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 347a9d9..261c4bc 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -4753,7 +4753,12 @@ local_timezone(PyDateTime_DateTime *utc_time) PyObject *nameo = NULL; const char *zone = NULL; - delta = datetime_subtract((PyObject *)utc_time, PyDateTime_Epoch); + delta = new_delta(ymd_to_ord(GET_YEAR(utc_time), GET_MONTH(utc_time), + GET_DAY(utc_time)) - 719163, + 60 * (60 * DATE_GET_HOUR(utc_time) + + DATE_GET_MINUTE(utc_time)) + + DATE_GET_SECOND(utc_time), + 0, 0); if (delta == NULL) return NULL; one_second = new_delta(0, 1, 0, 0); |