Commit aee044e8 authored by Stefan Behnel's avatar Stefan Behnel

properly handle char values (bytes with length 1) in Py3

parent 850c569f
......@@ -676,7 +676,7 @@ class CharNode(ConstNode):
return ord(self.value)
def calculate_result_code(self):
return "'%s'" % StringEncoding.escape_character(self.value)
return "'%s'" % StringEncoding.escape_char(self.value)
class IntNode(ConstNode):
......
......@@ -49,7 +49,7 @@ class BytesLiteralBuilder(object):
self.chars.append(characters)
def append_charval(self, char_number):
self.chars.append( chr(char_number) )
self.chars.append( chr(char_number).encode('ISO-8859-1') )
def getstring(self):
# this *must* return a byte string! => fix it in Py3k!!
......@@ -132,7 +132,8 @@ def _build_specials_test():
_has_specials = _build_specials_test()
def escape_character(c):
def escape_char(c):
c = c.decode('ISO-8859-1')
if c in '\n\r\t\\':
return repr(c)[1:-1]
elif c == "'":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment