@@ -173,7 +173,11 @@ always available.
173173
174174 Call ``func(*args) ``, while tracing is enabled. The tracing state is saved,
175175 and restored afterwards. This is intended to be called from a debugger from
176- a checkpoint, to recursively debug some other code.
176+ a checkpoint, to recursively debug or profile some other code.
177+
178+ Tracing is suspended while calling a tracing function set by
179+ :func: `settrace ` or :func: `setprofile ` to avoid infinite recursion.
180+ :func: `!call_tracing ` enables explicit recursion of the tracing function.
177181
178182
179183.. data :: copyright
@@ -1439,13 +1443,16 @@ always available.
14391443 its return value is not used, so it can simply return ``None ``. Error in the profile
14401444 function will cause itself unset.
14411445
1446+ .. note ::
1447+ The same tracing mechanism is used for :func: `!setprofile ` as :func: `settrace `.
1448+ To trace calls with :func: `!setprofile ` inside a tracing function
1449+ (e.g. in a debugger breakpoint), see :func: `call_tracing `.
1450+
14421451 Profile functions should have three arguments: *frame *, *event *, and
14431452 *arg *. *frame * is the current stack frame. *event * is a string: ``'call' ``,
14441453 ``'return' ``, ``'c_call' ``, ``'c_return' ``, or ``'c_exception' ``. *arg * depends
14451454 on the event type.
14461455
1447- .. audit-event :: sys.setprofile "" sys.setprofile
1448-
14491456 The events have the following meaning:
14501457
14511458 ``'call' ``
@@ -1467,6 +1474,9 @@ always available.
14671474 ``'c_exception' ``
14681475 A C function has raised an exception. *arg * is the C function object.
14691476
1477+ .. audit-event :: sys.setprofile "" sys.setprofile
1478+
1479+
14701480.. function :: setrecursionlimit(limit)
14711481
14721482 Set the maximum depth of the Python interpreter stack to *limit *. This limit
@@ -1526,6 +1536,10 @@ always available.
15261536 If there is any error occurred in the trace function, it will be unset, just
15271537 like ``settrace(None) `` is called.
15281538
1539+ .. note ::
1540+ Tracing is disabled while calling the trace function (e.g. a function set by
1541+ :func: `!settrace `). For recursive tracing see :func: `call_tracing `.
1542+
15291543 The events have the following meaning:
15301544
15311545 ``'call' ``
0 commit comments