From 513e4bf63e1f96937212dabdc08545baca63a74d Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Thu, 8 Aug 2019 00:02:35 -0500 Subject: [PATCH] Add KeyboardInterrupt class --- vm/src/builtins.rs | 2 ++ vm/src/exceptions.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/vm/src/builtins.rs b/vm/src/builtins.rs index 36d96c5b9..b17add5d1 100644 --- a/vm/src/builtins.rs +++ b/vm/src/builtins.rs @@ -915,6 +915,8 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) { "ResourceWarning" => ctx.exceptions.resource_warning.clone(), "RuntimeWarning" => ctx.exceptions.runtime_warning.clone(), "UserWarning" => ctx.exceptions.user_warning.clone(), + + "KeyboardInterrupt" => ctx.exceptions.keyboard_interrupt.clone(), }); } diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index 862c27c2d..dcd299217 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -238,6 +238,8 @@ pub struct ExceptionZoo { pub resource_warning: PyClassRef, pub runtime_warning: PyClassRef, pub user_warning: PyClassRef, + + pub keyboard_interrupt: PyClassRef, } impl ExceptionZoo { @@ -288,6 +290,8 @@ impl ExceptionZoo { let runtime_warning = create_type("RuntimeWarning", &type_type, &warning); let user_warning = create_type("UserWarning", &type_type, &warning); + let keyboard_interrupt = create_type("KeyboardInterrupt", &type_type, &base_exception_type); + ExceptionZoo { arithmetic_error, assertion_error, @@ -330,6 +334,7 @@ impl ExceptionZoo { runtime_warning, reference_error, user_warning, + keyboard_interrupt, } } }