mirror of https://github.com/openXC7/prjxray.git
utils: Fix an instability in cmp method.
Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
This commit is contained in:
parent
522ac7901c
commit
2950a63769
11
utils/cmp.py
11
utils/cmp.py
|
|
@ -106,8 +106,17 @@ def cmp(a, b):
|
|||
>>> cmp(b'AA', b'A')
|
||||
1
|
||||
|
||||
>>> def bit(*args):
|
||||
... return args
|
||||
>>> a = ('CLBLL', 'L', 'SLICEL', ('X', 0), 'AFFMUX', 'XOR')
|
||||
>>> b = ('CLBLL', 'L', 'SLICEL', ('X', 0), 'AFFMUX', ('F', 7))
|
||||
>>> cmp(a, b)
|
||||
-1
|
||||
>>> cmp(b, a)
|
||||
1
|
||||
|
||||
"""
|
||||
if not isinstance(a, (str, bytes)):
|
||||
if not isinstance(a, (str, bytes)) and not isinstance(b, (str, bytes)):
|
||||
try:
|
||||
for i, j in itertools.zip_longest(iter(a), iter(b)):
|
||||
r = cmp(i, j)
|
||||
|
|
|
|||
Loading…
Reference in New Issue