Message10615
Naively code like the following in org.python.core.Py would work to support isinstance (with similar work for issubclass):
static boolean recursiveIsInstance(PyObject inst, PyObject cls) {
if (cls instanceof PyClass && inst instanceof PyInstance) {
...
}
if (cls instanceof PyJavaType) {
Class proxyType = ((PyJavaType) cls).getProxyType();
if (proxyType != null) {
return proxyType.isAssignableFrom(inst.getClass());
}
}
if (cls instanceof PyType) {
...
However this causes a large number of failures in the regrtest:
[exec] 10 fails unexpected:
[exec] test_dict_jy test_imaplib test_java_subclasses
[exec] test_pythoninterpreter_jy test_robotparser test_signal
[exec] test_smtpnet test_ssl test_threading_jy test_urllibnet
(Only test_ssl should be failing right now, due to other issues.)
Python and Java have two different type systems, which Jython bridges. But just because a list (as implemented by PyList) can be used where a java.util.List is expected - including in Java - doesn't mean they have the same API in Python itself.
One possibility, although I haven't thought through possible bad implications, is to support the register method from Python's abstract base classes on the Python type representing a Java interface, eg
List.register(list)
See https://docs.python.org/2/library/abc.html#abc.ABCMeta.register
I'm going to reject for now, but if we can figure out a way to make this work, we should certainly reconsider. |
|
Date |
User |
Action |
Args |
2016-01-11 03:56:40 | zyasoft | set | messageid: <1452484600.74.0.878469385214.issue1779@psf.upfronthosting.co.za> |
2016-01-11 03:56:40 | zyasoft | set | recipients:
+ zyasoft, fwierzbicki, babelmania |
2016-01-11 03:56:40 | zyasoft | link | issue1779 messages |
2016-01-11 03:56:39 | zyasoft | create | |
|