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 Zuzu_Typ, josh.r, rhettinger, skrah
Date 2019-04-02.17:59:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554227943.8.0.47291616069.issue36379@roundup.psfhosted.org>
In-reply-to
Content
skrah: Is there any reason your patch, as written, wouldn't work? If you need a test case to verify, gmpy2's xmpz type supports in place pow (but requires the modulus to be None, since there is no normal way to pass it anyway), so you can just test:

    >>> xm = gmpy2.xmpz(2)
    >>> xm.__ipow__(3, 5)

Right now, that code will raise a TypeError (from check_num_args in wrap_binary_func):

    TypeError: expected 1 argument, got 2

while:

    >>> xm.__ipow__(3)

typically results in:

    SystemError: modulo not expected

because wrap_binaryfunc fails to pass the expected argument so the receiver sees garbage, and xmpz's ipow implementation checks the third argument raises an exception if anything but None is received; barring a coincidence of Py_None being on the stack there, it'll always fail the test.

Changing to wrap_ternaryfunc should make xm.__ipow__(3, 5) raise the SystemError currently raised by xm.__ipow__(3) (because it doesn't accept non-None), while xm.__ipow__(3) will work correctly.
History
Date User Action Args
2019-04-02 17:59:03josh.rsetrecipients: + josh.r, rhettinger, skrah, Zuzu_Typ
2019-04-02 17:59:03josh.rsetmessageid: <1554227943.8.0.47291616069.issue36379@roundup.psfhosted.org>
2019-04-02 17:59:03josh.rlinkissue36379 messages
2019-04-02 17:59:03josh.rcreate