[pypy-commit] pypy py3.5: fix for 1e117d8ffc90

arigo pypy.commits at gmail.com
Wed Feb 1 07:52:01 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r89877:c700ecba3a07
Date: 2017-02-01 13:51 +0100
http://bitbucket.org/pypy/pypy/changeset/c700ecba3a07/

Log:	fix for 1e117d8ffc90

diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py
--- a/lib-python/3/datetime.py
+++ b/lib-python/3/datetime.py
@@ -1145,18 +1145,17 @@
     def __hash__(self):
         """Hash."""
         if self._hashcode == -1:
+            # PyPy: uses the same algo as _datetimemodule.c, which
+            # unlike the pure Python version always relies on the
+            # nondeterministic hash on strings
+            temp1 = timedelta(hours=self._hour,
+                              minutes=self._minute,
+                              seconds=self._second,
+                              microseconds=self._microsecond)
             tzoff = self.utcoffset()
-            if not tzoff:  # zero or None
-                self._hashcode = hash(self._getstate()[0])
-            else:
-                # PyPy: uses the same algo as _datetimemodule.c, which
-                # unlike the pure Python version always relies on the
-                # nondeterministic hash on strings
-                seconds = self.hour * 3600 + self.minute * 60 + self.second
-                temp1 = timedelta(seconds=self.seconds,
-                                  microseconds=self.microseconds)
-                temp2 = temp1 - tzoff
-                self._hashcode = hash(temp2)
+            if tzoff:  # not zero, not None
+                temp1 -= tzoff
+            self._hashcode = hash(temp1)
         return self._hashcode
 
     # Conversion to string


More information about the pypy-commit mailing list