diff --git a/IPython/Itpl.py b/IPython/Itpl.py index ce21a87..0003e30 100644 --- a/IPython/Itpl.py +++ b/IPython/Itpl.py @@ -94,8 +94,16 @@ def matchorfail(text, pos): match = tokenprog.match(text, pos) if match is None: raise ItplError(text, pos) + return match, match.end() +try: + itpl_encoding = sys.stdin.encoding or 'ascii' +except AttributeError: + itpl_encoding = 'ascii' + + + class Itpl: """Class representing a string with interpolation abilities. @@ -104,7 +112,7 @@ class Itpl: evaluation and substitution happens in the namespace of the caller when str(instance) is called.""" - def __init__(self, format,codec=sys.stdin.encoding,encoding_errors='backslashreplace'): + def __init__(self, format,codec=itpl_encoding,encoding_errors='backslashreplace'): """The single mandatory argument to this constructor is a format string.