From faf296fa74a760e065b5b20ff8d1c72573196b0d Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sun, 3 May 2015 05:19:14 +0200 Subject: [PATCH] Fix bug with scripts that have UTF-8 characters. The parser expects bytes, not unicode. --- lslopt/lslparse.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lslopt/lslparse.py b/lslopt/lslparse.py index dd9bd49..122f020 100644 --- a/lslopt/lslparse.py +++ b/lslopt/lslparse.py @@ -2252,14 +2252,10 @@ list lazy_list_set(list L, integer i, list v) 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 not unicode: - try: - self.script = script.decode('utf8') - except UnicodeDecodeError as E: - self.errorpos = E.start - raise EParse(self, 'Invalid UTF-8 in script') + if type(script) is unicode: + script = script.encode('utf8') + self.script = script self.length = len(script) # Extended expressions in globals (needs support from the optimizer to work)