Skip to content

Commit f209929

Browse files
authored
Merge pull request #1413 from ChJR/hotfix/exit
Fix exit()
2 parents a957006 + 1cf11f5 commit f209929

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

tests/snippets/exit.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from testutils import assert_raises
2+
3+
with assert_raises(SystemExit):
4+
exit()

vm/src/builtins.rs

+1
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) {
883883
"UserWarning" => ctx.exceptions.user_warning.clone(),
884884

885885
"KeyboardInterrupt" => ctx.exceptions.keyboard_interrupt.clone(),
886+
"SystemExit" => ctx.exceptions.system_exit.clone(),
886887
});
887888
}
888889

vm/src/exceptions.rs

+3
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ pub struct ExceptionZoo {
252252
pub user_warning: PyClassRef,
253253

254254
pub keyboard_interrupt: PyClassRef,
255+
pub system_exit: PyClassRef,
255256
}
256257

257258
impl ExceptionZoo {
@@ -303,6 +304,7 @@ impl ExceptionZoo {
303304
let user_warning = create_type("UserWarning", &type_type, &warning);
304305

305306
let keyboard_interrupt = create_type("KeyboardInterrupt", &type_type, &base_exception_type);
307+
let system_exit = create_type("SystemExit", &type_type, &base_exception_type);
306308

307309
ExceptionZoo {
308310
arithmetic_error,
@@ -347,6 +349,7 @@ impl ExceptionZoo {
347349
reference_error,
348350
user_warning,
349351
keyboard_interrupt,
352+
system_exit,
350353
}
351354
}
352355
}

0 commit comments

Comments
 (0)