Add and test overflow handling, working around a Cython bug.