Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion extra_tests/snippets/syntax_non_utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

dir_path = os.path.dirname(os.path.realpath(__file__))

with assert_raises(ValueError):
# TODO: RUSTPYTHON. At some point snippets will fail and it will look confusing
# and out of the blue. This is going to be the cause and it's going to happen when
# the github worker for MacOS starts using Python 3.11.4.
if platform.python_implementation == "CPython" and platform.system() == 'Darwin':
expectedException = ValueError
else:
expectedException = SyntaxError

with assert_raises(expectedException):
with open(os.path.join(dir_path , "non_utf8.txt")) as f:
eval(f.read())
3 changes: 2 additions & 1 deletion vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ mod builtins {
Either::A(either) => {
let source: &[u8] = &either.borrow_bytes();
if source.contains(&0) {
return Err(vm.new_value_error(
return Err(vm.new_exception_msg(
vm.ctx.exceptions.syntax_error.to_owned(),
"source code string cannot contain null bytes".to_owned(),
));
}
Expand Down