From: SourceForge.net <no...@so...> - 2005-06-30 08:32:32
|
Bugs item #1230210, was opened at 2005-06-30 10:32 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1230210&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Johan M. Hahn (johahn) Assigned to: Nobody/Anonymous (nobody) Summary: isinstance(2.0, float) fails with jikes Initial Comment: Obviously, the jikes compiler outputs different byte code than javac. I was using jikes 1.21 to build jython 2.2a2 as of 2005-06-18, and noticed that isinstance(2.0, float) returned 0. This only happens with jikes and could indicate a bug in the project (or in jikes, but that is more unlikely). After some debugging I found out where things differ. In Py.isInstance.. if (cls instanceof PyType) { PyType objtype = obj.getType(); => if (objtype == cls) return true; return objtype.isSubType((PyType) cls); } else if (cls instanceof PyClass) { .. the identity check fails with jikes, while it passes with javac. So somehow, with jikes, there are two instances of PyType for PyFloat. Looking in PyFloat one see it caches its PyType.. private static final PyType FLOATTYPE = PyType. fromClass(PyFloat.class); .. and submits it to the PyObject constructor.. public PyFloat(double v) { super(FLOATTYPE); value = v; } .. so that the default constructor in PyObject doesn't have to look it up on each instantiation. If I comment out super(FLOATTYPE) above, everything works again. But since I find the caching sound I don't want to do that. What's even more strange is that PyInteger does the exact same caching, but isinstance(2, int) works just fine. The real bug it seems to me, is that PyType. fromClass(PyFloat.class) can return different objects when it is supposed not to. After looking at it though, I can't figure out what might go wrong. ...johahn ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1230210&group_id=12867 |