Commit 64bc9769 authored by Boxiang Sun's avatar Boxiang Sun

add __name__ attr to method-wrapper

parent eb3e468e
......@@ -1595,6 +1595,12 @@ static Box* builtinFunctionOrMethodName(Box* b, void*) {
return incref(func->name);
}
static Box* wrapperobjectName(Box* w, void*) {
assert(w->cls == wrapperobject_cls);
BoxedWrapperObject* wrapper_obj = static_cast<BoxedWrapperObject*>(w);
return boxString(wrapper_obj->descr->wrapper->name);
}
static Box* functionCode(Box* self, void*) {
assert(self->cls == function_cls);
BoxedFunction* func = static_cast<BoxedFunction*>(self);
......@@ -4531,6 +4537,8 @@ void setupRuntime() {
instancemethod_cls->giveAttr("im_class", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT,
offsetof(BoxedInstanceMethod, im_class), true));
wrapperobject_cls->giveAttrDescriptor("__name__", wrapperobjectName, NULL);
slice_cls->giveAttr(
"__new__",
new BoxedFunction(FunctionMetadata::create((void*)sliceNew, UNKNOWN, 4, false, false), { NULL, None }));
......
......@@ -5,4 +5,5 @@ print type(C).__str__ is object.__str__
print type(None).__str__ is object.__str__
print type(None).__str__ is None.__str__
print type(None.__str__)
print(None.__str__.__name__)
print type(type(None).__str__.__get__(None, type(None)))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment