Issue1878

classification
Title: Defer to Iterable for __iter__ if Java Map implements iterable
Type: Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: espeed, fwierzbicki, zyasoft
Priority: normal Keywords:

Created on 2012-04-27.12:37:32 by espeed, last changed 2014-05-21.22:17:20 by zyasoft.

Messages
msg7067 (view) Author: James Thornton (espeed) Date: 2012-04-27.12:37:32
Jython 2.5.2 is throwing this TypeError when met with a Java Map that is already itarable:

temp_id = Peer.tempid("db.part/user")
TypeError: Supertypes that share a modified attribute  have an MRO conflict[attribute=__iter__, types=[<type 'java.lang.Iterable'>, <type 'java.util.Map'>]]

Here's the Jython source that contains the error message:

  https://gist.github.com/2506332

See https://groups.google.com/d/msg/datomic/b8iODxDmmvM/soOcdhcvFmgJ
msg7068 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-04-27.16:54:41
Thanks for the bug report James - your timing is good as we are closing in on a 2.5.3 and it would be very cool to see Datomic working with Jython.
msg7069 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-04-27.17:13:35
I'm sure I'm just reading the bug report wrong - I tried

import java.util.HashMap;
import java.util.Iterator;

public class IterableMap extends HashMap implements Iterable {
    public Iterator iterator() {
        return this.keySet().iterator();
    }
}

But that doesn't trigger an MRO conflict - do you have a simple code snippet that triggers the problem?
msg7070 (view) Author: James Thornton (espeed) Date: 2012-04-27.20:50:17
Sure Frank -- here's a snippet that generates the error:

https://gist.github.com/2512943

Also notice the try/except hacks around Peer.tempid, conn.db, and Peer.q -- those are wrapped in a try/except block and then each method is immediately called again because it only generates an error the first time the method is called.
msg7071 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-04-28.04:35:37
Hi James - thanks for the snippet - but I'm not currently a user of Datomic - is it possible for you to come up with a code snippet that doesn't have external dependencies - that will greatly help me get to the bottom of the bug.
msg8035 (view) Author: Jim Baker (zyasoft) Date: 2013-05-31.04:36:28
Issue seen in another Clojure project, Storm. Should be readily resolvable by special casing in PyJavaType.
msg8041 (view) Author: Jim Baker (zyasoft) Date: 2013-06-11.17:14:35
Potential fix in this branch:
https://bitbucket.org/jimbaker/proxies

Still needs decent test cases that do not depend on Storm/Clojure.
msg8045 (view) Author: Jim Baker (zyasoft) Date: 2013-06-14.19:56:16
Fixed as of 7110:8d2f8c3a2299
History
Date User Action Args
2014-05-21 22:17:20zyasoftsetstatus: open -> closed
2013-06-14 19:56:16zyasoftsetresolution: accepted -> fixed
messages: + msg8045
2013-06-11 17:14:35zyasoftsetmessages: + msg8041
2013-05-31 04:36:29zyasoftsetmessages: + msg8035
2013-05-31 04:33:38zyasoftsetassignee: zyasoft
resolution: accepted
nosy: + zyasoft
2013-02-25 21:56:33fwierzbickisetpriority: normal
versions: + Jython 2.5, - 2.5.2
2012-04-28 04:35:37fwierzbickisetpriority: high -> (no value)
assignee: fwierzbicki -> (no value)
messages: + msg7071
2012-04-27 20:50:17espeedsetmessages: + msg7070
2012-04-27 17:13:35fwierzbickisetmessages: + msg7069
2012-04-27 16:54:41fwierzbickisetpriority: high
assignee: fwierzbicki
messages: + msg7068
nosy: + fwierzbicki
2012-04-27 12:37:32espeedcreate