Issue2754
Created on 2019-04-01.06:35:11 by jeff.allen, last changed 2019-04-01.06:35:11 by jeff.allen.
History | |||
---|---|---|---|
Date | User | Action | Args |
2019-04-01 06:35:11 | jeff.allen | create |
Created on 2019-04-01.06:35:11 by jeff.allen, last changed 2019-04-01.06:35:11 by jeff.allen.
Messages | |||
---|---|---|---|
msg12416 (view) | Author: Jeff Allen (jeff.allen) | Date: 2019-04-01.06:35:11 | |
I came across this trying to increase test coverage under #2746, but I think it is not specifically about mapping types but something I don't properly understand about proxies. When a proxy type sub-class is not a global variable, it is not found when Py.initProxy is called from code generated by org.python.compiler.JavaMaker.addProxy(). Py.initProxy is supplied a module name and a (simple) class name, but then it looks in that module for the name as an attribute, which may not be where it is. This simple program reproduces it the probjem: *** proxy_init_bug.py *** from java.util import HashMap class C(HashMap): pass print C.fromkeys('abc', 42) # works def f(): class D(HashMap): pass print D.fromkeys('abc', 42) f() The part involving class C is only there to demonstrate that it works correctly at the top level. The attempt by Py.initProxy to look-up D in __main__ produces a confusing message: PS jython-jvm9> dist\bin\jython proxy_init_bug.py {u'a': 42, u'b': 42, u'c': 42} Traceback (most recent call last): File "proxy_init_bug.py", line 10, in <module> f() File "proxy_init_bug.py", line 8, in f print D.fromkeys('abc', 42) AttributeError: 'module' object has no attribute 'D' |
History | |||
---|---|---|---|
Date | User | Action | Args |
2019-04-01 06:35:11 | jeff.allen | create |
Supported by Python Software Foundation,
Powered by Roundup