Skip to content
Snippets Groups Projects
Unverified Commit 550c44b8 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub
Browse files

gh-92839: fixed typo in _bisectmodule.c (line 131) (GH-92849) (#93321)

parent 9912b3d9
Branches
Tags
No related merge requests found
......@@ -257,6 +257,12 @@ def test_insort(self):
target
)
def test_insort_keynotNone(self):
x = []
y = {"a": 2, "b": 1}
for f in (self.module.insort_left, self.module.insort_right):
self.assertRaises(TypeError, f, x, y, key = "b")
class TestBisectPython(TestBisect, unittest.TestCase):
module = py_bisect
......
Fixed crash resulting from calling bisect.insort() or bisect.insort_left() with the key argument not equal to None.
......@@ -118,7 +118,7 @@ _bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x,
index = internal_bisect_right(a, x, lo, hi, key);
} else {
key_x = PyObject_CallOneArg(key, x);
if (x == NULL) {
if (key_x == NULL) {
return NULL;
}
index = internal_bisect_right(a, key_x, lo, hi, key);
......@@ -245,7 +245,7 @@ _bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x,
index = internal_bisect_left(a, x, lo, hi, key);
} else {
key_x = PyObject_CallOneArg(key, x);
if (x == NULL) {
if (key_x == NULL) {
return NULL;
}
index = internal_bisect_left(a, key_x, lo, hi, key);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment