mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Raise TypeError if BaseException receives Keyword arguments
This commit is contained in:
1 parent
bbf7aacd4d
commit
7623668256
2 files changed
+3
-2
No files matched your search
Vendored
-2
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user