[New-bugs-announce] [issue25549] call sum on list of timedelta throws TypeError

Kevin Jing Qiu report at bugs.python.org
Tue Nov 3 23:11:46 EST 2015


New submission from Kevin Jing Qiu:

Calling sum() on a list of timedelta objects results in TypeError: unsupported operand type(s) for +: 'int' and 'datetime.timedelta'

Here's a script that illustrates this behaviour:  (also attached)

import datetime

x = [datetime.timedelta(1), datetime.timedelta(2)]
print(x[0] + x[1])  # datetime.timedelta(3)
print(sum(x))  # TypeError: unsupported operand type(s) for +: 'int' and 'datetime.timedelta'


The bug is present in all version of Python 2 and Python 3

----------
components: Library (Lib)
files: demo.py
messages: 254038
nosy: kevinjqiu
priority: normal
severity: normal
status: open
title: call sum on list of timedelta throws TypeError
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40938/demo.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25549>
_______________________________________


More information about the New-bugs-announce mailing list