[issue18629] future division breaks timedelta division by integer

Jean-Paul Calderone report at bugs.python.org
Fri Aug 2 17:22:11 CEST 2013


New submission from Jean-Paul Calderone:

datetime.timedelta instances are divisible by integers on Python 2.7, but not when __future__.division has been turned on:


exarkun at top:~$ ~/Projects/cpython/2.7/python -c '
from datetime import timedelta
print timedelta(seconds=3) / 2
'
0:00:01.500000
exarkun at top:~$ ~/Projects/cpython/2.7/python -c '
from __future__ import division
from datetime import timedelta
print timedelta(seconds=3) / 2
'
Traceback (most recent call last):
  File "<string>", line 4, in <module>
TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'int'
exarkun at top:~$ ~/Projects/cpython/2.7/python
Python 2.7.5+ (2.7:8205e72b5cfc, Aug  2 2013, 11:12:04) 

This presents a minor barrier to Python 3 transitions, since it prevents the use of __future__.division in a module trying to retain Python 2 compatibility where timedelta division is used.

----------
components: Library (Lib)
messages: 194181
nosy: exarkun
priority: normal
severity: normal
status: open
title: future division breaks timedelta division by integer
type: behavior
versions: Python 2.7

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


More information about the Python-bugs-list mailing list