]> granicus.if.org Git - python/commitdiff
Issue #27834: Avoid overflow error in ZoneInfo.invert().
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Tue, 23 Aug 2016 18:44:51 +0000 (14:44 -0400)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Tue, 23 Aug 2016 18:44:51 +0000 (14:44 -0400)
Lib/test/datetimetester.py

index a0583072d9ec221af6ed3a28bc7f0ceb3ba902a5..e21d487a12e306f6483f45ea9e877b4002eff303 100644 (file)
@@ -4477,11 +4477,11 @@ class ZoneInfo(tzinfo):
 
     @staticmethod
     def invert(ut, ti):
-        lt = (ut.__copy__(), ut.__copy__())
+        lt = (array('q', ut), array('q', ut))
         if ut:
             offset = ti[0][0] // SEC
-            lt[0][0] = max(-2**31, lt[0][0] + offset)
-            lt[1][0] = max(-2**31, lt[1][0] + offset)
+            lt[0][0] += offset
+            lt[1][0] += offset
             for i in range(1, len(ut)):
                 lt[0][i] += ti[i-1][0] // SEC
                 lt[1][i] += ti[i][0] // SEC