diff options
author | Steve Dower <steve.dower@python.org> | 2022-07-17 16:11:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-17 16:11:24 +0100 |
commit | 044a593cbbe1639e906e06c47504dd1020ddfee4 (patch) | |
tree | ad204fabeee64b9015959c73398a9e41f51213eb /Python | |
parent | 5c19ddab65f91d190ec94c494e95c5d551a45efc (diff) | |
download | cpython-044a593cbbe1639e906e06c47504dd1020ddfee4.tar.gz cpython-044a593cbbe1639e906e06c47504dd1020ddfee4.zip |
gh-91348: Restore frame argument to sys._getframe audit event (GH-94928)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/sysmodule.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 93120071b40..a5fa551b957 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -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] |