This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gumtree
Recipients gumtree
Date 2011-10-08.22:58:36
SpamBayes Score 0.00027188737
Marked as misclassified No
Message-id <1318114717.45.0.0615506676272.issue13137@psf.upfronthosting.co.za>
In-reply-to
Content
I believe that the use of __future__.division may have unintended consequences with user types that define division.

The following fails:

	from __future__ import division

	class NumericType(object):
		def __init__(self,x):
			self.x = x

		def __div__(self,rhs):
			return self.x/rhs

	print NumericType(3.0) / 2.0

with the error message

  File "C:\proj_py\learning\future_bug\future.py", line 10, in <module>
    print NumericType(3.0) / 2.0
TypeError: unsupported operand type(s) for /: 'NumericType' and 'float'

Remove the line `from __future__ import division` and everything works fine.

I am using Python 2.7.2
History
Date User Action Args
2011-10-08 22:58:37gumtreesetrecipients: + gumtree
2011-10-08 22:58:37gumtreesetmessageid: <1318114717.45.0.0615506676272.issue13137@psf.upfronthosting.co.za>
2011-10-08 22:58:36gumtreelinkissue13137 messages
2011-10-08 22:58:36gumtreecreate