From: Finn B. <bc...@us...> - 2001-02-14 22:26:52
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv12467 Modified Files: PyProxy.java Py.java Log Message: Call the instance ctor when the first access to a proxy meythod is issued. This help a little with bug #129363. The new __initProxy__ method can be called from the java superclass and that will help for the rest. More about this problem will be added to faq. Index: PyProxy.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyProxy.java,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** PyProxy.java 2001/02/01 16:41:11 2.4 --- PyProxy.java 2001/02/14 22:27:32 2.5 *************** *** 11,13 **** --- 11,15 ---- abstract public void _setPySystemState(PySystemState ss); abstract public PySystemState _getPySystemState(); + + abstract public void __initProxy__(Object[] args); } Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -r2.35 -r2.36 *** Py.java 2001/02/04 15:07:32 2.35 --- Py.java 2001/02/14 22:27:32 2.36 *************** *** 276,281 **** public static PyObject jfindattr(PyProxy proxy, String name) { PyInstance o = proxy._getPyInstance(); ! if (o == null) ! return null; PyObject ret = o.__jfindattr__(name); if (ret == null) --- 276,283 ---- public static PyObject jfindattr(PyProxy proxy, String name) { PyInstance o = proxy._getPyInstance(); ! if (o == null) { ! proxy.__initProxy__(new Object[0]); ! o = proxy._getPyInstance(); ! } PyObject ret = o.__jfindattr__(name); if (ret == null) *************** *** 710,721 **** String[] modules) { - // System.out.println("initProxy"); - // frozen = false; initProperties(null, packages, props, frozenPackage, modules, proxy.getClass().getClassLoader()); ThreadState ts = getThreadState(); ! if (ts.getInitializingProxy() != null) { ! proxy._setPyInstance(ts.getInitializingProxy()); proxy._setPySystemState(ts.systemState); return; --- 712,728 ---- String[] modules) { initProperties(null, packages, props, frozenPackage, modules, proxy.getClass().getClassLoader()); + if (proxy._getPyInstance() != null) + return; + ThreadState ts = getThreadState(); ! PyInstance instance = ts.getInitializingProxy(); ! if (instance != null) { ! if (instance.javaProxy != null) ! throw Py.TypeError("Proxy instance reused"); ! instance.javaProxy = proxy; ! proxy._setPyInstance(instance); proxy._setPySystemState(ts.systemState); return; *************** *** 723,727 **** //System.out.println("path: "+sys.path.__str__()); - PyObject mod; // ??pending: findClass or should avoid sys.path loading? --- 730,733 ---- *************** *** 742,748 **** PyClass pyc = (PyClass)mod.__getattr__(pyclass.intern()); ! PyInstance instance = new PyInstance(pyc); instance.javaProxy = proxy; ! proxy._setPyInstance((PyInstance)instance); proxy._setPySystemState(ts.systemState); --- 748,754 ---- PyClass pyc = (PyClass)mod.__getattr__(pyclass.intern()); ! instance = new PyInstance(pyc); instance.javaProxy = proxy; ! proxy._setPyInstance(instance); proxy._setPySystemState(ts.systemState); |