D2553: templatefilters: avoid infinite recursion bug in stringify

2018-03-02 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9b6b02a5b589: templatefilters: avoid infinite recursion bug 
in stringify (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2553?vs=6349=6362

REVISION DETAIL
  https://phab.mercurial-scm.org/D2553

AFFECTED FILES
  mercurial/templatefilters.py

CHANGE DETAILS

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -376,6 +376,12 @@
 """
 thing = templatekw.unwraphybrid(thing)
 if util.safehasattr(thing, '__iter__') and not isinstance(thing, bytes):
+if isinstance(thing, str):
+# This is only reachable on Python 3 (otherwise
+# isinstance(thing, bytes) would have been true), and is
+# here to prevent infinite recursion bugs on Python 3.
+raise error.ProgrammingError(
+'stringify got unexpected unicode string: %r' % thing)
 return "".join([stringify(t) for t in thing if t is not None])
 if thing is None:
 return ""



To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2553: templatefilters: avoid infinite recursion bug in stringify

2018-03-02 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This doesn't ever happen on Python 2, but it's been a persistent pain
  on Python 3. Adding this helped produce some of my upcoming Python 3
  fixes.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2553

AFFECTED FILES
  mercurial/templatefilters.py

CHANGE DETAILS

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -376,6 +376,12 @@
 """
 thing = templatekw.unwraphybrid(thing)
 if util.safehasattr(thing, '__iter__') and not isinstance(thing, bytes):
+if isinstance(thing, str):
+# This is only reachable on Python 3 (otherwise
+# isinstance(thing, bytes) would have been true), and is
+# here to prevent infinite recursion bugs on Python 3.
+raise error.ProgrammingError(
+'stringify got unexpected unicode string: %r' % thing)
 return "".join([stringify(t) for t in thing if t is not None])
 if thing is None:
 return ""



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel