Message3901

Author pjenvey
Recipients pjenvey
Date 2008-12-10.05:16:09
SpamBayes Score 3.042011e-13
Marked as misclassified No
Message-id <1228886170.16.0.479575251288.issue1198@psf.upfronthosting.co.za>
In-reply-to
Content
Java integration's py2float doesn't consider __float__ for conversion. 
This is an issue with other conversions (py2int, etc) and likely affects  
more than the math module

Jython 2.5b0+ (trunk:5722:5725M, Dec 9 2008, 16:06:58) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> class F(object):
... 	def __float__(self):
... 		return 1.6
... 
>>> import math
>>> math.cos(F())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cos(): 1st arg can't be coerced to double

Python 2.5.2 (r252:60911, Apr 22 2008, 12:00:45) 
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class F(object):
...     def __float__(self):
...             return 1.6
... 
>>> import math
>>> math.cos(F())
-0.029199522301288815
History
Date User Action Args
2008-12-10 05:16:10pjenveysetrecipients: + pjenvey
2008-12-10 05:16:10pjenveysetmessageid: <1228886170.16.0.479575251288.issue1198@psf.upfronthosting.co.za>
2008-12-10 05:16:10pjenveylinkissue1198 messages
2008-12-10 05:16:09pjenveycreate