##// END OF EJS Templates
itpl.py: do not crash if no encoding set (e.g. eric ide)
Ville M. Vainio -
Show More
@@ -94,8 +94,16 b' def matchorfail(text, pos):'
94 94 match = tokenprog.match(text, pos)
95 95 if match is None:
96 96 raise ItplError(text, pos)
97
97 98 return match, match.end()
98 99
100 try:
101 itpl_encoding = sys.stdin.encoding or 'ascii'
102 except AttributeError:
103 itpl_encoding = 'ascii'
104
105
106
99 107 class Itpl:
100 108 """Class representing a string with interpolation abilities.
101 109
@@ -104,7 +112,7 b' class Itpl:'
104 112 evaluation and substitution happens in the namespace of the
105 113 caller when str(instance) is called."""
106 114
107 def __init__(self, format,codec=sys.stdin.encoding,encoding_errors='backslashreplace'):
115 def __init__(self, format,codec=itpl_encoding,encoding_errors='backslashreplace'):
108 116 """The single mandatory argument to this constructor is a format
109 117 string.
110 118
General Comments 0
You need to be logged in to leave comments. Login now