mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Err when invalid UTF-8 should have been generated in LSO mode.
LSO strings are byte arrays, but our strings are made for Mono which uses Unicode, and invalid UTF-8 sequences can't be stored in Unicode without using a custom representation. One possible representation is to only use the codepoints 0-255 in the Unicode string, to avoid supporting multiple types for strings. Something to study in future.
This commit is contained in:
parent
b593141f9f
commit
e8201d6956
2 changed files with 9 additions and 0 deletions
|
@ -475,6 +475,8 @@ def InternalUTF8toString(s):
|
||||||
# NOTE: Without the above line, the following one hits a bug in
|
# NOTE: Without the above line, the following one hits a bug in
|
||||||
# python-coverage. It IS executed but not detected.
|
# python-coverage. It IS executed but not detected.
|
||||||
continue
|
continue
|
||||||
|
if LSO:
|
||||||
|
raise ELSONotSupported("Byte strings not supported")
|
||||||
ret += u'?' * len(partialchar)
|
ret += u'?' * len(partialchar)
|
||||||
partialchar = b''
|
partialchar = b''
|
||||||
# fall through to process current character
|
# fall through to process current character
|
||||||
|
@ -482,11 +484,15 @@ def InternalUTF8toString(s):
|
||||||
partialchar = c
|
partialchar = c
|
||||||
pending = 1 if o < 0xE0 else 2 if o < 0xF0 else 3
|
pending = 1 if o < 0xE0 else 2 if o < 0xF0 else 3
|
||||||
elif o >= 0x80:
|
elif o >= 0x80:
|
||||||
|
if LSO:
|
||||||
|
raise ELSONotSupported("Byte strings not supported")
|
||||||
ret += u'?'
|
ret += u'?'
|
||||||
else:
|
else:
|
||||||
ret += c.decode('utf8')
|
ret += c.decode('utf8')
|
||||||
|
|
||||||
if partialchar:
|
if partialchar:
|
||||||
|
if LSO:
|
||||||
|
raise ELSONotSupported("Byte strings not supported")
|
||||||
ret += u'?' * len(partialchar)
|
ret += u'?' * len(partialchar)
|
||||||
|
|
||||||
return zstr(ret)
|
return zstr(ret)
|
||||||
|
|
|
@ -30,6 +30,9 @@ class Quaternion(tuple):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Quaternion(' + super(Quaternion, self).__repr__() + ')'
|
return 'Quaternion(' + super(Quaternion, self).__repr__() + ')'
|
||||||
|
|
||||||
|
class ELSONotSupported(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
# Recognized: 3763, 6466, 6495
|
# Recognized: 3763, 6466, 6495
|
||||||
Bugs = set([6495])
|
Bugs = set([6495])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue