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 hodgestar
Recipients hodgestar
Date 2020-10-01.15:10:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1601565002.5.0.364385542307.issue41903@roundup.psfhosted.org>
In-reply-to
Content
The documentation for PyNumber_InPlacePower [1] reads:

This is the equivalent of the Python statement o1 **= o2 when o3 is Py_None, or an in-place variant of pow(o1, o2, o3) otherwise. If o3 is to be ignored, pass Py_None in its place (passing NULL for o3 would cause an illegal memory access).

However, if a class A implements __ipow__ then PyNumber_InPlacePower(o1, o2, o3) ALWAYS ignores o3 if o1 is an instance of A.

This happens because if A implements __ipow__ then PyNumber_InPlacePower always calls the nb_inplace_power slot [2] and the slot always drops the third argument [3].

This appears to have always been the case in Python, so likely a small documentation patch is all that is required. If people agree, I will open a documentation pull request.

[1] https://docs.python.org/3/c-api/number.html?highlight=pynumber_inplacepower#c.PyNumber_InPlacePower

[2] https://github.com/python/cpython/blob/master/Objects/abstract.c#L1164

[3] https://github.com/python/cpython/blob/master/Objects/typeobject.c#L6631-L6636
History
Date User Action Args
2020-10-01 15:10:02hodgestarsetrecipients: + hodgestar
2020-10-01 15:10:02hodgestarsetmessageid: <1601565002.5.0.364385542307.issue41903@roundup.psfhosted.org>
2020-10-01 15:10:02hodgestarlinkissue41903 messages
2020-10-01 15:10:02hodgestarcreate