Issue761177

classification
Title: Problem comparing Java objects
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: emcastro, fwierzbicki
Priority: normal Keywords:

Created on 2003-06-26.13:32:00 by emcastro, last changed 2005-10-31.18:55:18 by fwierzbicki.

Messages
msg857 (view) Author: Emmanuel Castro (emcastro) Date: 2003-06-26.13:32:00
The result of the comparison of Java object in Jython is 
a random number !!!

Consider the following code:
-----------
from java.lang import Integer

for i in xrange(0,100):
	i52=Integer(52)
	i128=Integer(128)

	print i52<i128	
-----------
It prints out:
1
1
0
1
...

This is definitly not a good behavior.

I found a workaround by putting the following at the 
beginning of my code:

java.lang.Object.__lt__=lambda x,y: x.compareTo(y)<0
java.lang.Object.__le__=lambda x,y: x.compareTo(y)<=0
java.lang.Object.__eq__=lambda x,y: x.compareTo(y)==0
java.lang.Object.__ne__=lambda x,y: x.compareTo(y)!=0
java.lang.Object.__gt__=lambda x,y: x.compareTo(y)>0
java.lang.Object.__ge__=lambda x,y: x.compareTo(y)>=0
java.lang.Object.__cmp__=lambda x,y: x.compareTo(y)
	
I guess this could be fixed inside the org.python.core 
classes, but I could not find where the comparison takes 
place.
msg858 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2005-10-31.18:55:18
Logged In: YES 
user_id=193969

This is not a problem in 2.2
History
Date User Action Args
2003-06-26 13:32:00emcastrocreate