Yes, exactly, binary search is full of traps. And you may have missed one:
(left + right) // 2
is better written 'left + ((right - left) // 2)'. At least on some languages, I don't know which type Python will use there.'Nearly All Binary Searches and Mergesorts are Broken':
https://ai.googleblog.com/2006/06/extra-extra-read-all-about...