##// 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 match = tokenprog.match(text, pos)
94 match = tokenprog.match(text, pos)
95 if match is None:
95 if match is None:
96 raise ItplError(text, pos)
96 raise ItplError(text, pos)
97
97 return match, match.end()
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 class Itpl:
107 class Itpl:
100 """Class representing a string with interpolation abilities.
108 """Class representing a string with interpolation abilities.
101
109
@@ -104,7 +112,7 b' class Itpl:'
104 evaluation and substitution happens in the namespace of the
112 evaluation and substitution happens in the namespace of the
105 caller when str(instance) is called."""
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 """The single mandatory argument to this constructor is a format
116 """The single mandatory argument to this constructor is a format
109 string.
117 string.
110
118
General Comments 0
You need to be logged in to leave comments. Login now