Commit 2642c04e authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge #304

I added a bugfix to this branch for merging
parents 466b5204 8ad1f5b3
libunwind @ 68a2910b
Subproject commit c90a2e02b3c1b03362a549a05261a4d0513d6026
Subproject commit 68a2910bae7ed1bff8e1e03cd7239bfd7e1cfe79
......@@ -459,7 +459,7 @@ Box* getattrFunc(Box* obj, Box* _str, Box* default_value) {
Box* rtn = NULL;
try {
rtn = getattrInternal(obj, str->s, NULL);
rtn = getattr(obj, str->s.c_str());
} catch (ExcInfo e) {
if (!e.matches(AttributeError))
throw e;
......
......@@ -978,6 +978,23 @@ public:
HCAttrs* attrs = self->b->getHCAttrsPtr();
return boxInt(attrs->hcls->attr_offsets.size());
}
static Box* update(Box* _self, Box* _container) {
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
if (_container->cls == attrwrapper_cls) {
AttrWrapper* container = static_cast<AttrWrapper*>(_container);
HCAttrs* attrs = container->b->getHCAttrsPtr();
for (const auto& p : attrs->hcls->attr_offsets) {
self->b->setattr(p.first, attrs->attr_list->attrs[p.second], NULL);
}
} else {
RELEASE_ASSERT(0, "not implemented");
}
return None;
}
};
Box* makeAttrWrapper(Box* b) {
......@@ -1317,6 +1334,7 @@ void setupRuntime() {
attrwrapper_cls->giveAttr("values", new BoxedFunction(boxRTFunction((void*)AttrWrapper::values, LIST, 1)));
attrwrapper_cls->giveAttr("items", new BoxedFunction(boxRTFunction((void*)AttrWrapper::items, LIST, 1)));
attrwrapper_cls->giveAttr("__len__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::len, BOXED_INT, 1)));
attrwrapper_cls->giveAttr("update", new BoxedFunction(boxRTFunction((void*)AttrWrapper::update, NONE, 2)));
attrwrapper_cls->freeze();
// sys is the first module that needs to be set up, due to modules
......
......@@ -3,3 +3,18 @@ import functools
f = functools.partial(lambda *args: args, 1, 23)
print f("hello")
print f("world", 5)
def foo(x=1, y=2):
print ' inside foo:', x, y
return
def wrapper(f):
@functools.wraps(f)
def decorated(x=2, y=3):
f(x, y)
return decorated
for f in [foo, wrapper(foo)]:
print f.__name__
f()
f(3)
# fail-if: '-x' in EXTRA_JIT_ARGS
# I think pypa has an issue parsing decorator expressions if they aren't simple names
# https://github.com/vinzenz/libpypa/issues/15
......
# allow-warning: converting unicode literal to str
# fail-if: '-x' in EXTRA_JIT_ARGS
# Make sure we can spawn a bunch of threads
......
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