Skip to content

Commit 7d5d486

Browse files
committed
MNT: delete references to frame objects
This is to help prevent reference cycles between the frames and the locals in that frame. While garbage collection should in most cases take care of this eventually, we can help the interpreter out and break the cycle before we return.
1 parent db0c7c3 commit 7d5d486

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

lib/matplotlib/_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,5 @@ def warn_external(message, category=None):
385385
frame.f_globals.get("__name__", "")):
386386
break
387387
frame = frame.f_back
388+
del frame
388389
warnings.warn(message, category, stacklevel)

lib/matplotlib/cbook.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def _get_running_interactive_framework():
6767
if frame.f_code in codes:
6868
return "tk"
6969
frame = frame.f_back
70+
del frame
7071
macosx = sys.modules.get("matplotlib.backends._macosx")
7172
if macosx and macosx.event_loop_is_running():
7273
return "macosx"

0 commit comments

Comments
 (0)