Skip to content

Commit 2309e59

Browse files
authored
Merge pull request RustPython#3404 from DimitrisJim/genericalias_no_kwargs
Disallow kwargs from genericalias `__new__`.
2 parents 95bb1a1 + ffd7e8c commit 2309e59

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

vm/src/builtins/genericalias.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ impl PyValue for PyGenericAlias {
3939
}
4040
}
4141

42-
#[derive(FromArgs)]
43-
pub struct GenericAliasArgs {
44-
origin: PyTypeRef,
45-
arguments: PyObjectRef,
46-
}
47-
4842
impl Constructor for PyGenericAlias {
49-
type Args = GenericAliasArgs;
43+
type Args = FuncArgs;
5044

5145
fn py_new(cls: PyTypeRef, args: Self::Args, vm: &VirtualMachine) -> PyResult {
52-
PyGenericAlias::new(args.origin, args.arguments, vm).into_pyresult_with_type(vm, cls)
46+
if !args.kwargs.is_empty() {
47+
return Err(vm.new_type_error("GenericAlias() takes no keyword arguments".to_owned()));
48+
}
49+
let (origin, arguments): (_, PyObjectRef) = args.bind(vm)?;
50+
PyGenericAlias::new(origin, arguments, vm).into_pyresult_with_type(vm, cls)
5351
}
5452
}
5553

0 commit comments

Comments
 (0)