mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Makes type.__prepare__ a classmethod, also first arg is any (not str), refs #2762
This commit is contained in:
@@ -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) == {}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user