Message11592

Author zyasoft
Recipients bmvanwyk, tomluk, zyasoft
Date 2017-09-12.23:40:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505259648.82.0.723631764782.issue2445@psf.upfronthosting.co.za>
In-reply-to
Content
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()));
+                    }
                 }
             }
         }
History
Date User Action Args
2017-09-12 23:40:48zyasoftsetmessageid: <1505259648.82.0.723631764782.issue2445@psf.upfronthosting.co.za>
2017-09-12 23:40:48zyasoftsetrecipients: + zyasoft, tomluk, bmvanwyk
2017-09-12 23:40:48zyasoftlinkissue2445 messages
2017-09-12 23:40:47zyasoftcreate