Skip to content

Commit 8deb28e

Browse files
terml/nodes: Fix bags to have unordered comparisons.
1 parent 0ddeca3 commit 8deb28e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

terml/nodes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def __iter__(self):
2828

2929
def __eq__(self, other):
3030
try:
31+
if self.tag.name == ".bag." and other.tag.name == ".bag.":
32+
return (self.data, set(self.args)
33+
) == (other.data, set(other.args))
3134
return ( self.tag, self.data, self.args
3235
) == (other.tag, other.data, other.args)
3336
except AttributeError:
@@ -86,6 +89,8 @@ def __cmp__(self, other):
8689
datac = cmp(self.data, other.data)
8790
if datac:
8891
return datac
92+
if self.tag.name == ".bag." and other.tag.name == ".bag.":
93+
return cmp(set(self.args), set(other.args))
8994
return cmp(self.args, other.args)
9095

9196
def __int__(self):

0 commit comments

Comments
 (0)