Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r90072:7e28f9b94af3 Date: 2017-02-12 18:30 +0100 http://bitbucket.org/pypy/pypy/changeset/7e28f9b94af3/
Log: datetime.__hash__() was still deterministic if tzoff!=None. 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 @@ -1766,9 +1766,16 @@ if tzoff is None: self._hashcode = hash(self._getstate()[0]) else: + # PyPy: uses an algo that relies on the hash of strings, + # giving a nondeterministic result. CPython doesn't do + # that if there is a tzoff (but does if there is no + # tzoff). days = _ymd2ord(self.year, self.month, self.day) seconds = self.hour * 3600 + self.minute * 60 + self.second - self._hashcode = hash(timedelta(days, seconds, self.microsecond) - tzoff) + delta = timedelta(days, seconds, self.microsecond) - tzoff + temp1 = '%d&%d&%d' % (delta.days, delta.seconds, + delta.microseconds) + self._hashcode = hash(temp1) return self._hashcode # Pickle support. _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit