This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients josh.r
Date 2014-04-10.00:24:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397089497.66.0.725830795875.issue21193@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014-04-10 00:24:57josh.rsetrecipients: + josh.r
2014-04-10 00:24:57josh.rsetmessageid: <1397089497.66.0.725830795875.issue21193@psf.upfronthosting.co.za>
2014-04-10 00:24:57josh.rlinkissue21193 messages
2014-04-10 00:24:55josh.rcreate