Skip to content

Commit 0f2bd59

Browse files
committed
Make type() bases arg only take tuples
1 parent 472e535 commit 0f2bd59

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

vm/src/builtins/pytype.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use super::pystr::PyStrRef;
1515
use super::staticmethod::PyStaticMethod;
1616
use super::tuple::PyTuple;
1717
use super::weakref::PyWeak;
18+
use crate::builtins::tuple::PyTupleRef;
1819
use crate::function::{FuncArgs, KwArgs};
1920
use crate::pyobject::{
2021
BorrowValue, Either, IdProtocol, PyAttributes, PyClassImpl, PyContext, PyIterable, PyLease,
@@ -417,9 +418,12 @@ impl PyType {
417418
}));
418419
}
419420

420-
let (name, bases, dict, kwargs): (PyStrRef, PyIterable<PyTypeRef>, PyDictRef, KwArgs) =
421+
let (name, bases, dict, kwargs): (PyStrRef, PyTupleRef, PyDictRef, KwArgs) =
421422
args.clone().bind(vm)?;
422423

424+
// TODO: This is kind of a hack because we lose type information only to redo it
425+
let bases: PyIterable<PyTypeRef> =
426+
PyIterable::try_from_object(vm, bases.into_object()).unwrap();
423427
let bases: Vec<PyTypeRef> = bases.iter(vm)?.collect::<Result<Vec<_>, _>>()?;
424428
let (metatype, base, bases) = if bases.is_empty() {
425429
let base = vm.ctx.types.object_type.clone();

0 commit comments

Comments
 (0)