Makes type.__prepare__ a classmethod, also first arg is any (not str), refs #2762

This commit is contained in:
sobolevn
2021-08-08 12:49:41 +03:00
parent af63e83e13
commit e5e20a53b2
2 changed files with 6 additions and 2 deletions

View File

@@ -135,5 +135,8 @@ assert type.__prepare__('name', (bytes, str)) == {}
assert type.__prepare__(a=1, b=2) == {}
assert type.__prepare__('name', (object, int), kw=True) == {}
# Previously we needed `name` to be `str`:
assert type.__prepare__(1) == {}
assert int.__prepare__() == {}
assert int.__prepare__('name', (object, int), kw=True) == {}

View File

@@ -343,9 +343,10 @@ impl PyType {
.insert("__module__".to_owned(), value);
}
#[pymethod(magic)]
#[pyclassmethod(magic)]
fn prepare(
_name: OptionalArg<PyStrRef>,
_cls: PyTypeRef,
_name: OptionalArg<PyObjectRef>,
_bases: OptionalArg<PyObjectRef>,
_kwargs: KwArgs,
vm: &VirtualMachine,