diff options
author | Steve Dower <steve.dower@python.org> | 2021-05-03 13:06:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 13:06:36 (GMT) |
commit | bb2f3ff7a8f0c3565ccc1946dba7e09a3f7dc209 (patch) | |
tree | 6fea32214cc39992ce43a29309a1a1076b804ae4 /Objects | |
parent | 1536342c4491ffc70adeb540a04381e90ea623d7 (diff) | |
download | cpython-bb2f3ff7a8f0c3565ccc1946dba7e09a3f7dc209.zip cpython-bb2f3ff7a8f0c3565ccc1946dba7e09a3f7dc209.tar.gz cpython-bb2f3ff7a8f0c3565ccc1946dba7e09a3f7dc209.tar.bz2 |
bpo-42800: Add audit events for f_code and tb_frame (GH-24182)
Accessing the following attributes will now fire PEP 578 style audit hooks as (object.__getattr__, obj, name):
* PyTracebackObject: tb_frame
* PyFrameObject: f_code
* PyGenObject: gi_code, gi_frame
* PyCoroObject: cr_code, cr_frame
* PyAsyncGenObject: ag_code, ag_frame
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/frameobject.c | 2 | ||||
-rw-r--r-- | Objects/genobject.c | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c index b511e4c..50846de 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -13,7 +13,7 @@ static PyMemberDef frame_memberlist[] = { {"f_back", T_OBJECT, OFF(f_back), READONLY}, - {"f_code", T_OBJECT, OFF(f_code), READONLY}, + {"f_code", T_OBJECT, OFF(f_code), READONLY|READ_RESTRICTED}, {"f_builtins", T_OBJECT, OFF(f_builtins), READONLY}, {"f_globals", T_OBJECT, OFF(f_globals), READONLY}, {"f_lasti", T_INT, OFF(f_lasti), READONLY}, diff --git a/Objects/genobject.c b/Objects/genobject.c index 72c93f6..5ba4de8 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -711,9 +711,9 @@ static PyGetSetDef gen_getsetlist[] = { }; static PyMemberDef gen_memberlist[] = { - {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY}, + {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY|READ_RESTRICTED}, {"gi_running", T_BOOL, offsetof(PyGenObject, gi_running), READONLY}, - {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY}, + {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY|READ_RESTRICTED}, {NULL} /* Sentinel */ }; @@ -931,9 +931,9 @@ static PyGetSetDef coro_getsetlist[] = { }; static PyMemberDef coro_memberlist[] = { - {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY}, + {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY|READ_RESTRICTED}, {"cr_running", T_BOOL, offsetof(PyCoroObject, cr_running), READONLY}, - {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY}, + {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY|READ_RESTRICTED}, {"cr_origin", T_OBJECT, offsetof(PyCoroObject, cr_origin), READONLY}, {NULL} /* Sentinel */ }; @@ -1328,10 +1328,12 @@ static PyGetSetDef async_gen_getsetlist[] = { }; static PyMemberDef async_gen_memberlist[] = { - {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY}, + {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), + READONLY|READ_RESTRICTED}, {"ag_running", T_BOOL, offsetof(PyAsyncGenObject, ag_running_async), READONLY}, - {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), READONLY}, + {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), + READONLY|READ_RESTRICTED}, {NULL} /* Sentinel */ }; |