monty 0.0.20

A sandboxed, snapshotable Python interpreter written in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Test that bytes.decode raises UnicodeDecodeError for invalid UTF-8
# UnicodeDecodeError is a subclass of ValueError, so it should be caught by both

# Test it raises UnicodeDecodeError
raised_decode_error = False
try:
    b'\xff'.decode()
except UnicodeDecodeError:
    raised_decode_error = True
assert raised_decode_error

# Test it can be caught by ValueError (since UnicodeDecodeError is a subclass)
caught_by_value_error = False
try:
    b'\x80\x81'.decode()
except ValueError:
    caught_by_value_error = True
assert caught_by_value_error