Index: src/org/python/core/PyDictionary.java =================================================================== --- src/org/python/core/PyDictionary.java (revision 5366) +++ src/org/python/core/PyDictionary.java (working copy) @@ -428,13 +428,15 @@ PyObject arg = args[0]; if (arg.__findattr__("keys") != null) { merge(arg); + } else if (arg.__findattr__("keySet") != null) { + mergeFromKeys(arg, arg.invoke("keySet")); } else { mergeFromSeq(arg); } } for (int i = 0; i < keywords.length; i++) { dict___setitem__(Py.newString(keywords[i]), args[nargs + i]); - } + } } /** Index: bugtests/test403.py =================================================================== --- bugtests/test403.py (revision 0) +++ bugtests/test403.py (revision 0) @@ -0,0 +1,24 @@ +# +# Test for bug 1146 +# +# dict() should clone the Map +# + +from java.util import HashMap +import support + +x = HashMap() +x.put('foo', 1) +x.put('bar', 2) +x.put('baz', 3) + +try: + y = dict(x) + #print y + assert y.get('foo') == 1 + assert y.get('bar') == 2 + assert y.get('baz') == 3 +except ValueError, e: + raise support.TestError("Unable to pass a Map to dict().") +except AssertionError, e: + raise support.TestError("Failed to properly clone the Map.")