gh-91348: Restore frame argument to sys._getframe audit event (GH-94928)

This commit is contained in:
Steve Dower 2022-07-17 16:11:24 +01:00 committed by GitHub
parent 5c19ddab65
commit 044a593cbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 6 deletions

View file

@ -1772,10 +1772,6 @@ sys__getframe_impl(PyObject *module, int depth)
PyThreadState *tstate = _PyThreadState_GET();
_PyInterpreterFrame *frame = tstate->cframe->current_frame;
if (_PySys_Audit(tstate, "sys._getframe", NULL) < 0) {
return NULL;
}
if (frame != NULL) {
while (depth > 0) {
frame = frame->previous;
@ -1793,7 +1789,13 @@ sys__getframe_impl(PyObject *module, int depth)
"call stack is not deep enough");
return NULL;
}
return _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject(frame));
PyObject *pyFrame = Py_XNewRef((PyObject *)_PyFrame_GetFrameObject(frame));
if (pyFrame && _PySys_Audit(tstate, "sys._getframe", "(O)", pyFrame) < 0) {
Py_DECREF(pyFrame);
return NULL;
}
return pyFrame;
}
/*[clinic input]