Skip to content

Commit 910d557

Browse files
committed
fix compare stringmap with dict
1 parent 6443de2 commit 910d557

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/org/python/core/PyStringMap.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,19 @@ public boolean isSequenceType() {
523523
return false;
524524
}
525525

526+
@Override
527+
public PyObject richCompare(PyObject other, CompareOp op) {
528+
if (op == CompareOp.EQ && other instanceof PyDictionary) {
529+
for (PyObject key: ((PyDictionary) other).keys_as_list().asIterable()) {
530+
if (!get(key).equals(((PyDictionary) other).get(key))) {
531+
return Py.False;
532+
}
533+
}
534+
return Py.True;
535+
}
536+
return super.richCompare(other, op);
537+
}
538+
526539
private abstract class StringMapIter<T> extends PyIterator {
527540

528541
protected final Iterator<T> iterator;

0 commit comments

Comments
 (0)