Skip to content

Commit 27b8357

Browse files
authored
PEP-654: warn that leaf_generator recycles the tracebacks list (GH-2109)
1 parent 42c420f commit 27b8357

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pep-0654.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,12 @@ recursively, as follows:
469469
else:
470470
# exc is a leaf exception and its traceback
471471
# is the concatenation of the traceback
472-
# segments in tbs
472+
# segments in tbs.
473+
474+
# Note: the list returned (tbs) is reused in each iteration
475+
# through the generator. Make a copy if your use case holds
476+
# on to it beyond the current iteration or mutates its contents.
477+
473478
yield exc, tbs
474479
tbs.pop()
475480

0 commit comments

Comments
 (0)