From 0e450a5eff128b67c9c070dec1ff94a34ae17480 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 5 Aug 2012 14:22:53 +0200 Subject: [PATCH] src/callbacks.py: Use unicode_escape if running Python 3. --- src/callbacks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/callbacks.py b/src/callbacks.py index d34867525..59da1aa9e 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -284,7 +284,8 @@ class Tokenizer(object): def _handleToken(self, token): if token[0] == token[-1] and token[0] in self.quotes: token = token[1:-1] - token = token.encode().decode('string_escape') + encoding_prefix = 'string' if sys.version_info[0]<3 else 'unicode' + token = token.encode().decode(encoding_prefix + '_escape') return token def _insideBrackets(self, lexer):