.. from non UTF-8 inputs. In this case, MicroPython raises UnicodeError while CPython uses SyntaxError. By catching either exception, the test does not require an .exp file. Signed-off-by: Jeff Epler <jepler@gmail.com>
23 lines
474 B
Python
23 lines
474 B
Python
# test invalid UTF-8 string via eval
|
|
# Passing byte strings to exec/eval is a micropython extension
|
|
try:
|
|
eval(b"'ab\xa1'")
|
|
except SyntaxError:
|
|
print("Exception")
|
|
try:
|
|
eval(b"'ab\xf8'")
|
|
except SyntaxError:
|
|
print("Exception")
|
|
try:
|
|
eval(bytearray(b"'ab\xc0a'"))
|
|
except SyntaxError:
|
|
print("Exception")
|
|
try:
|
|
eval(b"'\xf0\xe0\xed\xe8'")
|
|
except SyntaxError:
|
|
print("Exception")
|
|
|
|
try:
|
|
exec(b"b\xff = 1")
|
|
except SyntaxError:
|
|
print("Exception")
|