Skip to content

Commit ad3baec

Browse files
committed
sequence: Fix yet another case of improper sequence comparison.
This time, in mp_seq_cmp_bytes(). How many more cases are still lurking?
1 parent 767e45c commit ad3baec

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

py/sequence.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, u
100100
}
101101
uint min_len = len1 < len2 ? len1 : len2;
102102
int res = memcmp(data1, data2, min_len);
103+
if (op == MP_BINARY_OP_EQUAL) {
104+
// If we are checking for equality, here're the answer
105+
return res == 0;
106+
}
103107
if (res < 0) {
104108
return false;
105109
}

tests/basics/bytes_compare.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@
4949
print(b"1" <= b"1/")
5050
print(b"10" <= b"1")
5151
print(b"1/" <= b"1")
52+
53+
print(b'o' == b'\n')

0 commit comments

Comments
 (0)