Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Lib/test/test_capi/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ def __ipow__(*args):

x = X()
self.assertEqual(inplacepower(x, 11), (x, 11))
# XXX: In-place power doesn't pass the third arg to __ipow__.
self.assertEqual(inplacepower(x, 11, 5), (x, 11))
self.assertEqual(inplacepower(x, 11, 5), (x, 11, 5))

def test_long(self):
# Test PyNumber_Long()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The default implementation of the
:c:member:`~PyNumberMethods.nb_inplace_power` slot no longer ignores the
third argument, but passes it to the :meth:`~object.__ipow__` method if its
value is not ``None``.
10 changes: 8 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9907,8 +9907,14 @@ SLOT1(slot_nb_inplace_remainder, __imod__, PyObject *)
static PyObject *
slot_nb_inplace_power(PyObject *self, PyObject * arg1, PyObject *arg2)
{
PyObject *stack[2] = {self, arg1};
return vectorcall_method(&_Py_ID(__ipow__), stack, 2);
if (arg2 == Py_None) {
PyObject *stack[2] = {self, arg1};
return vectorcall_method(&_Py_ID(__ipow__), stack, 2);
}
else {
PyObject *stack[3] = {self, arg1, arg2};
return vectorcall_method(&_Py_ID(__ipow__), stack, 3);
}
}
SLOT1(slot_nb_inplace_lshift, __ilshift__, PyObject *)
SLOT1(slot_nb_inplace_rshift, __irshift__, PyObject *)
Expand Down
Loading