D2171: ui: use named attributes on FrameInfo instance
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Mon Feb 12 03:45:45 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This type has been a named tuple since Python 2.6. Use the
named attributes to improve code clarity.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2171
AFFECTED FILES
mercurial/ui.py
CHANGE DETAILS
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1620,11 +1620,15 @@
else:
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
- self.write_err('%s at: %s:%s (%s)\n'
- % ((msg,) + calframe[stacklevel][1:4]))
+ frameinfo = calframe[stacklevel]
+
+ self.write_err('%s at: %s:%s (%s)\n' % (
+ msg, frameinfo.filename, frameinfo.lineno,
+ frameinfo.function))
self.log('develwarn', '%s at: %s:%s (%s)\n',
- msg, *calframe[stacklevel][1:4])
- curframe = calframe = None # avoid cycles
+ msg, frameinfo.filename, frameinfo.lineno,
+ frameinfo.function)
+ curframe = calframe = frameinfo = None # avoid cycles
def deprecwarn(self, msg, version, stacklevel=2):
"""issue a deprecation warning
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list