]> Devi Nivas Git - chevron.git/commitdiff
Fixed python 2 StringIO bug
authornoah morrison <noah@morrison.ph>
Thu, 6 Nov 2014 20:34:32 +0000 (15:34 -0500)
committernoah morrison <noah@morrison.ph>
Thu, 6 Nov 2014 20:34:32 +0000 (15:34 -0500)
In python 2 strings were not being converted to StringIOs.

The new method assumes that template is a string and tries to convert
it to a StringIO. If that fails then it assumes a file-like object.

entei.py

index 7e57a638f36c0a010e088540630e44cfee3a6714..6d6eef4e786fcba5e8ef175ec3854187b5231d25 100755 (executable)
--- a/entei.py
+++ b/entei.py
@@ -63,8 +63,10 @@ def tokenize(template):
         '&': 'no escape'
     }
 
-    if type(template) is str:
+    try:
         template = StringIO(template)
+    except TypeError:
+        pass
 
     open_sections = []
     l_del = '{{'