Closed
Description
Bug report
Bug description:
bisect functions raise TypeError when called with key argument.
Here is a minimum code to reproduce the issue:
import bisect
import operator
a = [('one', 1), ('two', 2)]
print(bisect.bisect(a, ('one', 1), key=operator.itemgetter(0)))
This results in the following error:
Traceback (most recent call last):
File "/path/to/bisect_test.py", line 5, in <module>
print(bisect.bisect(a, ('one', 1), key=operator.itemgetter(0)))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'tuple' and 'str'
It seems that picking an item in a tuple has a problem.
CPython versions tested on:
3.12
Operating systems tested on:
macOS