Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

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.

----------
versions: +Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36379>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to