Message11592
My suggestion in msg11591 works as expected. Need to look at some additional testing, but it should be part of 2.7.2:
diff -r 8d52ad2559f5 src/org/python/core/PyJavaType.java
--- a/src/org/python/core/PyJavaType.java Sat Sep 09 14:02:01 2017 -0600
+++ b/src/org/python/core/PyJavaType.java Tue Sep 12 17:38:22 2017 -0600
@@ -187,7 +187,15 @@
PyList types = new PyList();
Set<Class<?>> proxySet = Generic.set();
for (PyJavaType othertype : conflictedAttributes) {
- if (othertype.modified != null && othertype.modified.contains(method)) {
+ /* Ignore any pairings of types that are in a superclass/superinterface
+ * relationship with each other. This problem is a false positive that happens
+ * because of the automatic addition of methods so that Java classes behave
+ * more like their corresponding Python types, such as adding sort or remove.
+ * See http://bugs.jython.org/issue2445
+ */
+ if (othertype.modified != null && othertype.modified.contains(method) &&
+ !(othertype.getProxyType().isAssignableFrom(type.getProxyType()) ||
+ type.getProxyType().isAssignableFrom(othertype.getProxyType()))) {
types.add(othertype);
proxySet.add(othertype.getProxyType());
}
@@ -199,13 +207,16 @@
* __iter__. Annoying but necessary logic. See http://bugs.jython.org/issue1878
*/
if (method.equals("__iter__")
- && proxySet.equals(Generic.set(Iterable.class, Map.class))) {
+ && Generic.set(Iterable.class, Map.class).containsAll(proxySet)) {
continue;
}
- throw Py.TypeError(String.format(
- "Supertypes that share a modified attribute "
- + "have an MRO conflict[attribute=%s, supertypes=%s, type=%s]",
- method, types, this.getName()));
+
+ if (types.size() > 0) {
+ throw Py.TypeError(String.format(
+ "Supertypes that share a modified attribute "
+ + "have an MRO conflict[attribute=%s, supertypes=%s, type=%s]",
+ method, types, this.getName()));
+ }
}
}
} |
|
Date |
User |
Action |
Args |
2017-09-12 23:40:48 | zyasoft | set | messageid: <1505259648.82.0.723631764782.issue2445@psf.upfronthosting.co.za> |
2017-09-12 23:40:48 | zyasoft | set | recipients:
+ zyasoft, tomluk, bmvanwyk |
2017-09-12 23:40:48 | zyasoft | link | issue2445 messages |
2017-09-12 23:40:47 | zyasoft | create | |
|