Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5208,7 +5208,6 @@ def test_inspect_signatures(self):
]),
)

@unittest.expectedFailure # TODO: RUSTPYTHON; len is often/always > 256
def test_test_simple_enum(self):
@_simple_enum(Enum)
class SimpleColor:
Expand Down
10 changes: 8 additions & 2 deletions crates/vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
PyClassMethod, PyDictRef, PyList, PyStr, PyStrInterned, PyStrRef, PyTupleRef, PyWeak,
mappingproxy::PyMappingProxy, object, union_,
PyClassMethod, PyDictRef, PyList, PyStaticMethod, PyStr, PyStrInterned, PyStrRef, PyTupleRef,
PyWeak, mappingproxy::PyMappingProxy, object, union_,
};
use crate::{
AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyResult, TryFromObject,
Expand Down Expand Up @@ -1166,6 +1166,12 @@ impl Constructor for PyType {
*f = PyClassMethod::from(f.clone()).into_pyobject(vm);
}

if let Some(f) = attributes.get_mut(identifier!(vm, __new__))
&& f.class().is(vm.ctx.types.function_type)
{
*f = PyStaticMethod::from(f.clone()).into_pyobject(vm);
}

if let Some(current_frame) = vm.current_frame() {
let entry = attributes.entry(identifier!(vm, __module__));
if matches!(entry, Entry::Vacant(_)) {
Expand Down
2 changes: 2 additions & 0 deletions extra_tests/snippets/builtin_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ def __new__(cls, *args, **kwargs):
assert ClassWithNew().__new__.__qualname__ == "ClassWithNew.__new__"
assert ClassWithNew.__new__.__name__ == "__new__"
assert ClassWithNew().__new__.__name__ == "__new__"
assert isinstance(ClassWithNew.__dict__.get("__new__"), staticmethod)

assert ClassWithNew.N.__new__.__qualname__ == "ClassWithNew.N.__new__"
assert ClassWithNew().N.__new__.__qualname__ == "ClassWithNew.N.__new__"
Expand All @@ -593,6 +594,7 @@ def __new__(cls, *args, **kwargs):
assert ClassWithNew().N().__new__.__qualname__ == "ClassWithNew.N.__new__"
assert ClassWithNew.N().__new__.__name__ == "__new__"
assert ClassWithNew().N().__new__.__name__ == "__new__"
assert isinstance(ClassWithNew.N.__dict__.get("__new__"), staticmethod)


# Regression to:
Expand Down
Loading