src/callbacks.py: Use unicode_escape if running Python 3.

This commit is contained in:
Valentin Lorentz 2012-08-05 14:22:53 +02:00
parent 34bb33b65f
commit 0e450a5eff

View File

@ -284,7 +284,8 @@ class Tokenizer(object):
def _handleToken(self, token): def _handleToken(self, token):
if token[0] == token[-1] and token[0] in self.quotes: if token[0] == token[-1] and token[0] in self.quotes:
token = token[1:-1] 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 return token
def _insideBrackets(self, lexer): def _insideBrackets(self, lexer):