bpo-37937: Mention frame.f_trace in sys.settrace docs (GH-15439)

Mention frame.f_trace in sys.settrace docs, as well as the fact you still
need to call `sys.settrace` to enable the tracing machinery before setting
`frame.f_trace` will have any effect.
(cherry picked from commit 9c2682efc6)

Co-authored-by: Ram Rachum <ram@rachum.com>
This commit is contained in:
Miss Islington (bot) 2019-09-20 08:26:27 -07:00 committed by GitHub
parent 0ab6b01820
commit c410390e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -1324,6 +1324,17 @@ always available.
Note that as an exception is propagated down the chain of callers, an
``'exception'`` event is generated at each level.
For more fine-grained usage, it's possible to set a trace function by
assigning ``frame.f_trace = tracefunc`` explicitly, rather than relying on
it being set indirectly via the return value from an already installed
trace function. This is also required for activating the trace function on
the current frame, which :func:`settrace` doesn't do. Note that in order
for this to work, a global tracing function must have been installed
with :func:`settrace` in order to enable the runtime tracing machinery,
but it doesn't need to be the same tracing function (e.g. it could be a
low overhead tracing function that simply returns ``None`` to disable
itself immediately on each frame).
For more information on code and frame objects, refer to :ref:`types`.
.. audit-event:: sys.settrace "" sys.settrace

View File

@ -0,0 +1 @@
Mention ``frame.f_trace`` in :func:`sys.settrace` docs.