GH-131498: Cases generator: Allow input and 'peek' variables to be modified (GH-132506)

This commit is contained in:
Mark Shannon 2025-04-14 12:19:53 +01:00 committed by GitHub
parent be763e550e
commit 844596c09f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 90 additions and 116 deletions

View file

@ -6350,20 +6350,12 @@
}
case _MAKE_CALLARGS_A_TUPLE: {
_PyStackRef kwargs_in;
_PyStackRef callargs;
_PyStackRef func;
_PyStackRef tuple;
_PyStackRef kwargs_out;
kwargs_in = stack_pointer[-1];
callargs = stack_pointer[-2];
func = stack_pointer[-4];
PyObject *callargs_o = PyStackRef_AsPyObjectBorrow(callargs);
if (PyTuple_CheckExact(callargs_o)) {
tuple = callargs;
kwargs_out = kwargs_in;
}
else {
if (!PyTuple_CheckExact(callargs_o)) {
_PyFrame_SetStackPointer(frame, stack_pointer);
int err = _Py_Check_ArgsIterable(tstate, PyStackRef_AsPyObjectBorrow(func), callargs_o);
stack_pointer = _PyFrame_GetStackPointer(frame);
@ -6376,17 +6368,14 @@
if (tuple_o == NULL) {
JUMP_TO_ERROR();
}
kwargs_out = kwargs_in;
stack_pointer += -2;
assert(WITHIN_STACK_BOUNDS());
_PyStackRef temp = callargs;
callargs = PyStackRef_FromPyObjectSteal(tuple_o);
stack_pointer[-2] = callargs;
_PyFrame_SetStackPointer(frame, stack_pointer);
PyStackRef_CLOSE(callargs);
PyStackRef_CLOSE(temp);
stack_pointer = _PyFrame_GetStackPointer(frame);
tuple = PyStackRef_FromPyObjectSteal(tuple_o);
stack_pointer += 2;
}
stack_pointer[-2] = tuple;
stack_pointer[-1] = kwargs_out;
stack_pointer[-2] = callargs;
break;
}
@ -6631,15 +6620,17 @@
}
case _SWAP: {
_PyStackRef *top;
_PyStackRef *bottom;
_PyStackRef top;
_PyStackRef bottom;
oparg = CURRENT_OPARG();
top = &stack_pointer[-1];
bottom = &stack_pointer[-2 - (oparg-2)];
_PyStackRef temp = bottom[0];
bottom[0] = top[0];
top[0] = temp;
top = stack_pointer[-1];
bottom = stack_pointer[-2 - (oparg-2)];
_PyStackRef temp = bottom;
bottom = top;
top = temp;
assert(oparg >= 2);
stack_pointer[-2 - (oparg-2)] = bottom;
stack_pointer[-1] = top;
break;
}