Issue222829

classification
Title: PyProxy/PyObject mixup
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: bckfnn
Priority: low Keywords:

Created on 2000-11-18.19:20:28 by bckfnn, last changed 2000-11-18.22:45:20 by bckfnn.

Messages
msg103 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.19:20:28
    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?
msg104 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.22:45:20
Fixed by letting a proxy extend java.lang.Object instead of PyProxy.
History
Date User Action Args
2000-11-18 19:20:28bckfnncreate