Fix bug with scripts that have UTF-8 characters.

The parser expects bytes, not unicode.
This commit is contained in:
Sei Lisa 2015-05-03 05:19:14 +02:00
parent 621b29b0cc
commit faf296fa74

View file

@ -2252,14 +2252,10 @@ list lazy_list_set(list L, integer i, list v)
This function also builds the temporary globals table. This function also builds the temporary globals table.
""" """
self.script = script # needed here so there's a .script property for EParse in case of exception in decode() if type(script) is unicode:
if type(script) is not unicode: script = script.encode('utf8')
try:
self.script = script.decode('utf8')
except UnicodeDecodeError as E:
self.errorpos = E.start
raise EParse(self, 'Invalid UTF-8 in script')
self.script = script
self.length = len(script) self.length = len(script)
# Extended expressions in globals (needs support from the optimizer to work) # Extended expressions in globals (needs support from the optimizer to work)