[pypy-issue] [issue1060] datetime.utcfromtimestamp creates datetime objects which crash in __hash__
Beda Kosata
tracker at bugs.pypy.org
Thu Feb 16 20:32:07 CET 2012
New submission from Beda Kosata <beda.kosata at gmail.com>:
When a datetime object is created from a float using the utcfromtimestamp
classmethod, the resulting instance crashes on hash() and is thus unusable in
dict keys, etc.
>> from datetime import datetime
>> x = datetime.utcfromtimestamp(123456789.0)
>> hash(x)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/pypy-1.8/lib_pypy/datetime.py", line 1882, in __hash__
return hash(self._getstate()[0])
File "/opt/pypy-1.8/lib_pypy/datetime.py", line 1897, in _getstate
us1, us2, us3)
TypeError: expected integer, got float object
Instances created using fromtimestamp() behave as expected. The issue seems
specific to the utc method.
----------
messages: 3966
nosy: beda, pypy-issue
priority: bug
status: unread
title: datetime.utcfromtimestamp creates datetime objects which crash in __hash__
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1060>
________________________________________
More information about the pypy-issue
mailing list