diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-17 15:49:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-17 15:49:57 (GMT) |
commit | 1c63734217be75c9fd024ba8fad28ccb108b4d55 (patch) | |
tree | 6f4df4899dde2c7716ad5755d57cbbea47594686 /Python/sysmodule.c | |
parent | 65d87a2cb843d5f6af6489cb9784f55938196a28 (diff) | |
download | cpython-1c63734217be75c9fd024ba8fad28ccb108b4d55.zip cpython-1c63734217be75c9fd024ba8fad28ccb108b4d55.tar.gz cpython-1c63734217be75c9fd024ba8fad28ccb108b4d55.tar.bz2 |
gh-91348: Restore frame argument to sys._getframe audit event (GH-94928)
(cherry picked from commit 044a593cbbe1639e906e06c47504dd1020ddfee4)
Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'Python/sysmodule.c')
-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 261ebb9..e45a264 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1780,10 +1780,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; @@ -1801,7 +1797,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] |