diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-05-28 18:48:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-28 18:48:25 (GMT) |
commit | 550c44b89513ea96d209e2ff761302238715f082 (patch) | |
tree | e0383ee79d931b0f8cf5d06a9ec49efcfb06e8f1 | |
parent | 9912b3d989b0cb442e9f9d55fbdd30d55591e2fc (diff) | |
download | cpython-550c44b89513ea96d209e2ff761302238715f082.zip cpython-550c44b89513ea96d209e2ff761302238715f082.tar.gz cpython-550c44b89513ea96d209e2ff761302238715f082.tar.bz2 |
gh-92839: fixed typo in _bisectmodule.c (line 131) (GH-92849) (#93321)
-rw-r--r-- | Lib/test/test_bisect.py | 6 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-05-16-14-35-39.gh-issue-92839.owSMyo.rst | 1 | ||||
-rw-r--r-- | Modules/_bisectmodule.c | 4 |
3 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py index 20f8b9d..ba10822 100644 --- a/Lib/test/test_bisect.py +++ b/Lib/test/test_bisect.py @@ -257,6 +257,12 @@ class TestBisect: 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 diff --git a/Misc/NEWS.d/next/Library/2022-05-16-14-35-39.gh-issue-92839.owSMyo.rst b/Misc/NEWS.d/next/Library/2022-05-16-14-35-39.gh-issue-92839.owSMyo.rst new file mode 100644 index 0000000..b425bd9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-16-14-35-39.gh-issue-92839.owSMyo.rst @@ -0,0 +1 @@ +Fixed crash resulting from calling bisect.insort() or bisect.insort_left() with the key argument not equal to None. diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c index 26c4b9b..16f981e 100644 --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -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); |