Skip to content

gh-102249: Expand sys.call_tracing documentation #102806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 31, 2023
Merged
Changes from 7 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
17 changes: 15 additions & 2 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ always available.

Call ``func(*args)``, while tracing is enabled. The tracing state is saved,
and restored afterwards. This is intended to be called from a debugger from
a checkpoint, to recursively debug some other code.
a checkpoint, to recursively debug or profile some other code.

Tracing is suspended while calling a tracing function set by
:func:`settrace` or :func:`setprofile` to avoid infinite recursion.
:func:`!call_tracing` enables explicit recursion of the tracing function.


.. data:: copyright
Expand Down Expand Up @@ -1392,7 +1396,12 @@ always available.
``'return'``, ``'c_call'``, ``'c_return'``, or ``'c_exception'``. *arg* depends
on the event type.

.. audit-event:: sys.setprofile "" sys.setprofile
.. note::
The same tracing mechanism is used for :func:`!setprofile` as :func:`settrace`.
To trace calls with :func:`!setprofile` inside a tracing function (e.g. in a
debugger breakpoint) see :func:`call_tracing`.

.. audit-event:: sys.setprofile "" sys.setprofile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry if I was unclear before—the note should go one block above, and the audit-event should go where the `note used to be (i.e. below the list of event values. This will avoid interjecting these two between the introduction of the profile function args and the description of their values, which is particularly confusing to readers because the audit "events" are entirely unrelated to the event argument here.

Also, the indents got off as a result of this change.

As I should have before, here's a patch you can apply with

git apply 0001-Move-call_tracing-note-audit-event-in-setprofile-to-.patch

to fix all this directly:

0001-Move-call_tracing-note-audit-event-in-setprofile-to-.patch


The events have the following meaning:

Expand Down Expand Up @@ -1475,6 +1484,10 @@ always available.
If there is any error occurred in the trace function, it will be unset, just
like ``settrace(None)`` is called.

.. note::
Tracing is disabled while calling the trace function (e.g. a function set by
:func:`!settrace`). For recursive tracing see :func:`call_tracing`.

The events have the following meaning:

``'call'``
Expand Down