#1565525: Add traceback.clear_frames() helper function to clear locals ref'd by a traceback

This commit is contained in:
Andrew Kuchling 2013-09-15 18:15:56 -04:00
parent 8408dc581e
commit 173a157e72
5 changed files with 62 additions and 1 deletions

View file

@ -129,6 +129,13 @@ The module defines the following functions:
A shorthand for ``format_list(extract_stack(f, limit))``.
.. function:: clear_frames(tb)
Clears the local variables of all the stack frames in a traceback *tb*
by calling the :meth:`clear` method of each frame object.
.. versionadded:: 3.4
.. _traceback-example:

View file

@ -377,6 +377,14 @@ plain tuple. (Contributed by Claudiu Popa in :issue:`18901`.)
:meth:`sunau.open` now supports the context manager protocol (:issue:`18878`).
traceback
---------
A new :func:`traceback.clear_frames` function takes a traceback object
and clears the local variables in all of the frames it references,
reducing the amount of memory consumed (:issue:`1565525`).
urllib
------