bpo-39453: Add testcase for bpo-39453 (GH-18202)

https://github.com/python/cpython/commit/9e1ed518a576897f914227bf538bac426a0... commit: 9e1ed518a576897f914227bf538bac426a02a081 branch: master author: Dong-hee Na <donghee.na92@gmail.com> committer: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> date: 2020-01-27T09:04:25-08:00 summary: bpo-39453: Add testcase for bpo-39453 (GH-18202) https://bugs.python.org/issue39453 Automerge-Triggered-By: @pablogsal Automerge-Triggered-By: @pablogsal files: M Lib/test/test_list.py M Objects/listobject.c diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py index 33a55f76d9b2c..3c8d82958fd7c 100644 --- a/Lib/test/test_list.py +++ b/Lib/test/test_list.py @@ -225,6 +225,8 @@ def __eq__(self, other): # to list elements while calling PyObject_RichCompareBool(). lst = [X(), X()] 3 in lst + lst = [X(), X()] + X() in lst if __name__ == "__main__": diff --git a/Objects/listobject.c b/Objects/listobject.c index 38055d5f5f341..2c07ceb0d412c 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -452,7 +452,7 @@ list_contains(PyListObject *a, PyObject *el) for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i) { item = PyList_GET_ITEM(a, i); Py_INCREF(item); - cmp = PyObject_RichCompareBool(PyList_GET_ITEM(a, i), el, Py_EQ); + cmp = PyObject_RichCompareBool(item, el, Py_EQ); Py_DECREF(item); } return cmp;
participants (1)
-
Miss Islington (bot)