Patchwork D2171: ui: use named attributes on FrameInfo instance

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 3:45 a.m.
Message ID <differential-rev-PHID-DREV-xlqyuana3zaizqh7vj4x-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27642/
State Superseded
Headers show

Comments

phabricator - Feb. 12, 2018, 3:45 a.m.
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




To: indygreg, #hg-reviewers
Cc: mercurial-devel
Augie Fackler - Feb. 13, 2018, 3:08 a.m.
This one I'm going to have to discard, along with D2172. I'll mail my version instead. Sigh.

> On Feb 12, 2018, at 21:48, indygreg (Gregory Szorc) <phabricator@mercurial-scm.org> wrote:
> 
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rHGffcc3b977e43: ui: use named attributes on FrameInfo instance (authored by indygreg, committed by ).
> 
> REPOSITORY
>  rHG Mercurial
> 
> CHANGES SINCE LAST UPDATE
>  https://phab.mercurial-scm.org/D2171?vs=5472&id=5594
> 
> 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, pulkit, durin42
> Cc: mercurial-devel

Patch

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