I'm glad you caught that! First things first: the converted code should behave identically to the existing code, including raising the same exceptions.
If you examine the exception hierarchy:
http://docs.python.org/3.4/library/exceptions.html#exception-hierarchy
you'll see that "OverflowError" is a subclass of "ArithmeticError". In other words, it represents when you perform an arithmetic operation that overflows the result type. Using it to also represent "you specified a value that is out of range for this conversion" seems wrong.
So I like #3 as well.
Could _PyLong_UnsignedInt_Converter catch the OverflowError raised by PyLong_AsUnsignedLong and reraise it as ValueError? |