mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-105375: Improve array.array exception handling (GH-105594) (#105644)
Fix a bug where 'tp_richcompare' could end up overwriting an exception.
(cherry picked from commit 35cff545db
)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
bf6e0e618a
commit
d3c69ed366
2 changed files with 7 additions and 3 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Fix a bug in :class:`array.array` where an exception could end up being
|
||||||
|
overwritten.
|
|
@ -739,10 +739,12 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
||||||
k = 1;
|
k = 1;
|
||||||
for (i = 0; i < Py_SIZE(va) && i < Py_SIZE(wa); i++) {
|
for (i = 0; i < Py_SIZE(va) && i < Py_SIZE(wa); i++) {
|
||||||
vi = getarrayitem(v, i);
|
vi = getarrayitem(v, i);
|
||||||
|
if (vi == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
wi = getarrayitem(w, i);
|
wi = getarrayitem(w, i);
|
||||||
if (vi == NULL || wi == NULL) {
|
if (wi == NULL) {
|
||||||
Py_XDECREF(vi);
|
Py_DECREF(vi);
|
||||||
Py_XDECREF(wi);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
k = PyObject_RichCompareBool(vi, wi, Py_EQ);
|
k = PyObject_RichCompareBool(vi, wi, Py_EQ);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue