diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 000ef02d9..47e789496 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -668,8 +668,6 @@ class ExceptionTests(unittest.TestCase): e.__suppress_context__ = False self.assertFalse(e.__suppress_context__) - # TODO: RUSTPYTHON - @unittest.expectedFailure def testKeywordArgs(self): # test that builtin exception don't take keyword args, # but user-defined subclasses can if they want diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index 66ceeca67..0b61c9017 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -649,6 +649,9 @@ impl Constructor for PyBaseException { type Args = FuncArgs; fn py_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult { + if cls.is(PyBaseException::class(&vm.ctx)) && !args.kwargs.is_empty() { + return Err(vm.new_type_error("BaseException() takes no keyword arguments".to_owned())); + } PyBaseException::new(args.args, vm) .into_ref_with_type(vm, cls) .map(Into::into)