forked from Rust-related/RustPython
Properly pass kwargs to metaclass in builtin_build_class
This commit is contained in:
@@ -959,7 +959,10 @@ pub fn builtin_build_class_(
|
||||
|
||||
let class = vm.invoke(
|
||||
metaclass.as_object(),
|
||||
vec![name_obj, bases, namespace.into_object()],
|
||||
(
|
||||
Args::from(vec![name_obj, bases, namespace.into_object()]),
|
||||
kwargs,
|
||||
),
|
||||
)?;
|
||||
cells.set_item("__class__", class.clone(), vm)?;
|
||||
Ok(class)
|
||||
|
||||
@@ -44,6 +44,16 @@ impl From<PyObjectRef> for PyFuncArgs {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(Args, KwArgs)> for PyFuncArgs {
|
||||
fn from(arg: (Args, KwArgs)) -> Self {
|
||||
let Args(args) = arg.0;
|
||||
let KwArgs(kwargs) = arg.1;
|
||||
PyFuncArgs {
|
||||
args,
|
||||
kwargs: kwargs.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<(&Args, &KwArgs)> for PyFuncArgs {
|
||||
fn from(arg: (&Args, &KwArgs)) -> Self {
|
||||
let Args(args) = arg.0;
|
||||
@@ -293,6 +303,11 @@ impl<T> Args<T> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
impl<T> From<Vec<T>> for Args<T> {
|
||||
fn from(v: Vec<T>) -> Self {
|
||||
Args(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PyValue> Args<PyRef<T>> {
|
||||
pub fn into_tuple(self, vm: &VirtualMachine) -> PyObjectRef {
|
||||
|
||||
Reference in New Issue
Block a user