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 <>
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


    >>> 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.
Date User Action Args
2019-04-02 17:59:03josh.rsetrecipients: + josh.r, rhettinger, skrah, Zuzu_Typ
2019-04-02 17:59:03josh.rsetmessageid: <>
2019-04-02 17:59:03josh.rlinkissue36379 messages
2019-04-02 17:59:03josh.rcreate