memcmp() can return values other than -1, 0, and +1 but tp_compare
must not.
This commit is contained in:
parent
b0061c8e93
commit
ab1049c046
|
@ -233,6 +233,9 @@ print 'Buffers'
|
||||||
try: buffer('asdf', -1)
|
try: buffer('asdf', -1)
|
||||||
except ValueError: pass
|
except ValueError: pass
|
||||||
else: raise TestFailed, "buffer('asdf', -1) should raise ValueError"
|
else: raise TestFailed, "buffer('asdf', -1) should raise ValueError"
|
||||||
|
cmp(buffer("abc"), buffer("def")) # used to raise a warning: tp_compare didn't return -1, 0, or 1
|
||||||
|
|
||||||
|
cmp(buffer('abc'), buffer('def'))
|
||||||
|
|
||||||
try: buffer(None)
|
try: buffer(None)
|
||||||
except TypeError: pass
|
except TypeError: pass
|
||||||
|
|
|
@ -12,6 +12,8 @@ What's New in Python 2.5 release candidate 1?
|
||||||
Core and builtins
|
Core and builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Bug #1536786: buffer comparison could emit a RuntimeWarning.
|
||||||
|
|
||||||
- Bug #1535165: fixed a segfault in input() and raw_input() when
|
- Bug #1535165: fixed a segfault in input() and raw_input() when
|
||||||
sys.stdin is closed.
|
sys.stdin is closed.
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ buffer_compare(PyBufferObject *self, PyBufferObject *other)
|
||||||
if (min_len > 0) {
|
if (min_len > 0) {
|
||||||
cmp = memcmp(p1, p2, min_len);
|
cmp = memcmp(p1, p2, min_len);
|
||||||
if (cmp != 0)
|
if (cmp != 0)
|
||||||
return cmp;
|
return cmp < 0 ? -1 : 1;
|
||||||
}
|
}
|
||||||
return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0;
|
return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue