Message215860
While checking the exceptions used to compare existing behavior while investigating #20539, I noticed a weird behavior in pow() (implemented by long_pow in longobject.c). If a 3rd argument (the modulus) is provided, and the 2nd argument (the exponent) is negative, the function raises TypeError. To my knowledge, TypeError should never be used for this purpose; some functions raise OverflowError for negative values (which violates the documented purpose of OverflowError, but the documents don't match CPython's implementation), others use ValueError (which I believe is appropriate, since it's not a matter of a C type limitation, the function is just logically restricted to the range [0,Largest possible PyLong].
I recommend switching to ValueError, possibly with a deprecation notice before making the switch if people think someone might rely on this behavior.
Related: #457066 |
|
Date |
User |
Action |
Args |
2014-04-10 00:24:57 | josh.r | set | recipients:
+ josh.r |
2014-04-10 00:24:57 | josh.r | set | messageid: <1397089497.66.0.725830795875.issue21193@psf.upfronthosting.co.za> |
2014-04-10 00:24:57 | josh.r | link | issue21193 messages |
2014-04-10 00:24:55 | josh.r | create | |
|