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:
Sei Lisa 2016-12-13 14:26:48 +01:00
parent b593141f9f
commit e8201d6956
2 changed files with 9 additions and 0 deletions

View file

@ -475,6 +475,8 @@ def InternalUTF8toString(s):
# NOTE: Without the above line, the following one hits a bug in
# python-coverage. It IS executed but not detected.
continue
if LSO:
raise ELSONotSupported("Byte strings not supported")
ret += u'?' * len(partialchar)
partialchar = b''
# fall through to process current character
@ -482,11 +484,15 @@ def InternalUTF8toString(s):
partialchar = c
pending = 1 if o < 0xE0 else 2 if o < 0xF0 else 3
elif o >= 0x80:
if LSO:
raise ELSONotSupported("Byte strings not supported")
ret += u'?'
else:
ret += c.decode('utf8')
if partialchar:
if LSO:
raise ELSONotSupported("Byte strings not supported")
ret += u'?' * len(partialchar)
return zstr(ret)

View file

@ -30,6 +30,9 @@ class Quaternion(tuple):
def __repr__(self):
return 'Quaternion(' + super(Quaternion, self).__repr__() + ')'
class ELSONotSupported(Exception):
pass
# Recognized: 3763, 6466, 6495
Bugs = set([6495])