Patchwork D1088: templater: explode if we try to emit a str

login
register
mail settings
Submitter phabricator
Date Oct. 15, 2017, 1:27 p.m.
Message ID <76e4df5abef41bf11100c98780c3f840@localhost.localdomain>
Download mbox | patch
Permalink /patch/24948/
State Not Applicable
Headers show

Comments

phabricator - Oct. 15, 2017, 1:27 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb13c95919ff5: templater: explode if we try to emit a str (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1088?vs=2768&id=2778

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

AFFECTED FILES
  mercurial/templater.py

CHANGE DETAILS




To: durin42, #hg-reviewers, yuja
Cc: mercurial-devel

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1240,6 +1240,11 @@ 
     thing = templatekw.unwraphybrid(thing)
     if isinstance(thing, bytes):
         yield thing
+    elif isinstance(thing, str):
+        # We can only hit this on Python 3, and it's here to guard
+        # against infinite recursion.
+        raise error.ProgrammingError('Mercurial IO including templates is done'
+                                     ' with bytes, not strings')
     elif thing is None:
         pass
     elif not util.safehasattr(thing, '__iter__'):