Skip to content

Commit 7681892

Browse files
authored
Merge pull request RustPython#2342 from carbotaniuman/type
Make `type()` bases arg only take tuples
2 parents 472e535 + 6cb89fb commit 7681892

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

vm/src/builtins/pytype.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ use super::pystr::PyStrRef;
1515
use super::staticmethod::PyStaticMethod;
1616
use super::tuple::PyTuple;
1717
use super::weakref::PyWeak;
18+
use crate::builtins::tuple::PyTupleTyped;
1819
use crate::function::{FuncArgs, KwArgs};
1920
use crate::pyobject::{
20-
BorrowValue, Either, IdProtocol, PyAttributes, PyClassImpl, PyContext, PyIterable, PyLease,
21-
PyObjectRef, PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
21+
BorrowValue, Either, IdProtocol, PyAttributes, PyClassImpl, PyContext, PyLease, PyObjectRef,
22+
PyRef, PyResult, PyValue, TryFromObject, TypeProtocol,
2223
};
2324
use crate::slots::{self, Callable, PyTpFlags, PyTypeSlots, SlotGetattro};
2425
use crate::vm::VirtualMachine;
@@ -417,10 +418,10 @@ impl PyType {
417418
}));
418419
}
419420

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

423-
let bases: Vec<PyTypeRef> = bases.iter(vm)?.collect::<Result<Vec<_>, _>>()?;
424+
let bases = bases.borrow_value().to_vec();
424425
let (metatype, base, bases) = if bases.is_empty() {
425426
let base = vm.ctx.types.object_type.clone();
426427
(metatype, base.clone(), vec![base])

0 commit comments

Comments
 (0)