Commit 50128e6f authored by Kevin Modzelewski's avatar Kevin Modzelewski

Allow calling __call__ explicitly

We had a few places where we added BoxedBuiltinFunctionOrMethod, which don't
have bind-on-get behavior, causing issues with __call__
parent 1186883d
......@@ -1483,6 +1483,10 @@ void Box::appendNewHCAttr(BORROWED(Box*) new_attr, SetattrRewriteArgs* rewrite_a
}
void Box::giveAttr(STOLEN(BoxedString*) attr, STOLEN(Box*) val) {
// While it's certainly possible to put builtin_function_or_method objects on a type, this is in practice never
// what you want to do, because those objects don't have bind-on-get behavior.
assert(cls == module_cls || val->cls != builtin_function_or_method_cls);
assert(!this->hasattr(attr));
// Would be nice to have a stealing version of setattr:
this->setattr(attr, val, NULL);
......
......@@ -73,3 +73,8 @@ def f3():
D.__get__ = get
print type(C())
f3()
# misc tests:
import sys
sys.getrecursionlimit.__call__.__call__.__call__()
TypeError.__call__.__call__.__call__()
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