[PATCH] ui: drop values returned by inspect.*frame*() to avoid cycles
Jun Wu
quark at fb.com
Wed Aug 10 14:08:16 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1470837920 -3600
# Wed Aug 10 15:05:20 2016 +0100
# Node ID 1d492a4de1135415a890cd46c8622e4f339a9db8
# Parent 3df9f780c90ec179a2f87802f352a0273da9a364
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 1d492a4de113
ui: drop values returned by inspect.*frame*() to avoid cycles
"f = inspect.currentframe()" instantly creates a cycle because
"f.f_locals['a']" is "f" itself.
This patch explicitly sets those frame objects to None to avoid cycles.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1175,6 +1175,7 @@ class ui(object):
% ((msg,) + calframe[stacklevel][1:4]))
self.log('develwarn', '%s at: %s:%s (%s)\n',
msg, *calframe[stacklevel][1:4])
+ curframe = calframe = None
def deprecwarn(self, msg, version):
"""issue a deprecation warning
More information about the Mercurial-devel
mailing list