Message4583
The problem here is PythonClassB ends up with PythonClassA's javaProxy,
see its toString:
Jython 2.5b3+ (trunk:6258, Apr 23 2009, 18:06:50)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> from Issue1297_ import *
>>> PythonClassA()
org.python.proxies.Issue1297_$PythonClassA$1@bf2c60d
>>> PythonClassB() # should be a $PythonClassB$1 class
org.python.proxies.Issue1297_$PythonClassA$1@48caff01
This happens because PyType doesn't add PythonClassB's proxy type to its
__bases__ (so it's not in its mro) -- I guess PyType.setupProxy is being
too clever
>>> PythonClassA.mro()
[<class 'Issue1297_.PythonClassA'>, <type
'org.python.proxies.Issue1297_$PythonClassA$1'>, <type 'JavaClass'>,
<type 'java.lang.Object'>, <type 'object'>]
>>> PythonClassA.__bases__
(<type 'org.python.proxies.Issue1297_$PythonClassA$1'>,)
>>> PythonClassB.mro()
[<class 'Issue1297_.PythonClassB'>, <class 'Issue1297_.PythonClassA'>,
<type 'org.python.proxies.Issue1297_$PythonClassA$1'>, <type
'JavaClass'>, <type 'java.lang.Object'>, <type 'object'>]
>>> PythonClassB.__bases__
(<class 'Issue1297_.PythonClassA'>,)
So B inherits A's javaProxy's __init__, which is a
PyReflectedConstructor wired to create A's proxy. This problem actually
goes away when B defines an __init__ method that'd override it
I'm not exactly sure how to best layout bases/mro intertwined with the
proxys to fix this. Attached is a patch that fixes the problem by always
adding the javaProxy type to bases. But this breaks a couple
test_java_subclasses tests. Charlie, can you take a look at this for the
2.5rc? |
|
Date |
User |
Action |
Args |
2009-04-24 02:10:37 | pjenvey | set | messageid: <1240539037.18.0.937725388514.issue1297@psf.upfronthosting.co.za> |
2009-04-24 02:10:37 | pjenvey | set | recipients:
+ pjenvey, cgroves, fwierzbicki, zyasoft, alex.gronholm |
2009-04-24 02:10:36 | pjenvey | link | issue1297 messages |
2009-04-24 02:10:36 | pjenvey | create | |
|