From 0f2bd598372c585e2e9b615eebed0a428c32abe5 Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Tue, 24 Nov 2020 22:31:26 -0600 Subject: [PATCH] Make `type()` bases arg only take tuples --- vm/src/builtins/pytype.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vm/src/builtins/pytype.rs b/vm/src/builtins/pytype.rs index 498f0bb36..27c5706f0 100644 --- a/vm/src/builtins/pytype.rs +++ b/vm/src/builtins/pytype.rs @@ -15,6 +15,7 @@ use super::pystr::PyStrRef; use super::staticmethod::PyStaticMethod; use super::tuple::PyTuple; use super::weakref::PyWeak; +use crate::builtins::tuple::PyTupleRef; use crate::function::{FuncArgs, KwArgs}; use crate::pyobject::{ BorrowValue, Either, IdProtocol, PyAttributes, PyClassImpl, PyContext, PyIterable, PyLease, @@ -417,9 +418,12 @@ impl PyType { })); } - let (name, bases, dict, kwargs): (PyStrRef, PyIterable, PyDictRef, KwArgs) = + let (name, bases, dict, kwargs): (PyStrRef, PyTupleRef, PyDictRef, KwArgs) = args.clone().bind(vm)?; + // TODO: This is kind of a hack because we lose type information only to redo it + let bases: PyIterable = + PyIterable::try_from_object(vm, bases.into_object()).unwrap(); let bases: Vec = bases.iter(vm)?.collect::, _>>()?; let (metatype, base, bases) = if bases.is_empty() { let base = vm.ctx.types.object_type.clone();