Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 Doc/library/audit_events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Audit events table

This table contains all events raised by :func:`sys.audit` or
:c:func:`PySys_Audit` calls throughout the CPython runtime and the
standard library. These calls were added in 3.8.0 or later.
standard library. These calls were added in 3.8.0 or later (see :pep:`578`).

See :func:`sys.addaudithook` and :c:func:`PySys_AddAuditHook` for
information on handling these events.
Expand Down
3 changes: 3 additions & 0 deletions 3 Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4708,6 +4708,9 @@ environment. Code objects are returned by the built-in :func:`compile` function
and can be extracted from function objects through their :attr:`__code__`
attribute. See also the :mod:`code` module.

Accessing ``__code__`` raises an :ref:`auditing event <auditing>`
``object.__getattr__`` with arguments ``obj`` and ``"__code__"``.

.. index::
builtin: exec
builtin: eval
Expand Down
6 changes: 6 additions & 0 deletions 6 Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,9 @@ Internal types
:attr:`f_lasti` gives the precise instruction (this is an index into the
bytecode string of the code object).

Accessing ``f_code`` raises an :ref:`auditing event <auditing>`
``object.__getattr__`` with arguments ``obj`` and ``"f_code"``.

.. index::
single: f_trace (frame attribute)
single: f_trace_lines (frame attribute)
Expand Down Expand Up @@ -1084,6 +1087,9 @@ Internal types
:keyword:`try` statement with no matching except clause or with a
finally clause.

Accessing ``tb_frame`` raises an :ref:`auditing event <auditing>`
``object.__getattr__`` with arguments ``obj`` and ``"tb_frame"``.

.. index::
single: tb_next (traceback attribute)

Expand Down
1 change: 1 addition & 0 deletions 1 Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ Kevan Heydon
Wouter van Heyst
Kelsey Hightower
Jason Hildebrand
Ryan Hileman
Aaron Hill
Joel Hillacre
Richie Hindle
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Audit hooks are now fired for frame.f_code, traceback.tb_frame, and generator code/frame attribute access.
2 changes: 1 addition & 1 deletion 2 Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
14 changes: 8 additions & 6 deletions 14 Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,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 */
};

Expand Down Expand Up @@ -944,9 +944,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 */
};
Expand Down Expand Up @@ -1341,10 +1341,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 */
};

Expand Down
2 changes: 1 addition & 1 deletion 2 Python/traceback.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static PyMethodDef tb_methods[] = {
};

static PyMemberDef tb_memberlist[] = {
{"tb_frame", T_OBJECT, OFF(tb_frame), READONLY},
{"tb_frame", T_OBJECT, OFF(tb_frame), READONLY|READ_RESTRICTED},
{"tb_lasti", T_INT, OFF(tb_lasti), READONLY},
{"tb_lineno", T_INT, OFF(tb_lineno), READONLY},
{NULL} /* Sentinel */
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.