[issue5476] datetime: timedelta(minutes = i) silently fails with numpy.int32 input
Barron Henderson
report at bugs.python.org
Wed Mar 11 16:50:47 CET 2009
New submission from Barron Henderson <barronh at gmail.com>:
Initializing a timedelta object with numpy.int32 arguments give mixed
results; it fails for days keyword, gives bad results for minutes, and
give correct results for seconds/microseconds. Failure confirmed on
Linux i686 (Py 2.5.2; numpy 1.2.1) and OS X 10.5.6 (Py 2.5.1;
1.2.1).Test case below:
from datetime import timedelta
from numpy import int32
from numpy import int32
from datetime import timedelta
assert timedelta(seconds = 36) == timedelta(seconds = int32(36))
print 'pass 36 sec'
assert timedelta(microseconds = 36) == timedelta(microseconds = int32(36))
print 'pass 36 usec'
assert timedelta(minutes = 35) == timedelta(minutes = int32(35))
print 'pass 35 min'
assert timedelta(minutes = 36) == timedelta(minutes = int32(36))
print 'pass 36 min' # returns bad value
assert timedelta(days = 36) == timedelta(days = int32(36))
print 'pass 36 days' # fails SystemError: Objects/longobject.c:223
----------
messages: 83470
nosy: barronh
severity: normal
status: open
title: datetime: timedelta(minutes = i) silently fails with numpy.int32 input
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5476>
_______________________________________
More information about the Python-bugs-list
mailing list