Message103

Author bckfnn
Recipients
Date 2000-11-18.19:20:28
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
    I've had a maddening problem when writing testscripts for a
fairly complex application involving object factories and other
indirections.

    I have a JPython class that implements an object factory,
creating a JPython object implementing the required interfaces.

    However, in another JPython class that later on enumerates these
created objects, I no longer get back the originally created object.
The object is reported as org.python.proxy.Xxxx$, not the usual
<_Main_.Xxxx ...>.

    After checking out the code[1], I belive that org.python.core.Py.java2py
may be the culprit:

    public static PyObject java2py(Object o) {
        if (o instanceof PyObject)
            return (PyObject)o;

        if (o instanceof PyProxy)
            return ((PyProxy)o)._getPyInstance();

        if (o instanceof Number) {
        ...

    From the debug printout, it seems that my proxy object implemented 
both the PyProxy interface as well as the PyObject class. This of course
resulted in me getting the proxy object instead of the jpython object that
I wanted.

    By simply reversing the order of the test for PyProxy and PyObject,
the problem went away. However, it seems a bit too easy - is this the
bug, or is the real bug that a PyProxy also happens to inherit from 
PyObject?
History
Date User Action Args
2008-02-20 17:16:41adminlinkissue222829 messages
2008-02-20 17:16:41admincreate