Commit 013e6135 authored by Kevin Modzelewski's avatar Kevin Modzelewski

A few more fixes

parent c38f6248
...@@ -915,11 +915,9 @@ BORROWED(Box*) FrameInfo::updateBoxedLocals() { ...@@ -915,11 +915,9 @@ BORROWED(Box*) FrameInfo::updateBoxedLocals() {
Box* val = closure->elts[derefInfo.offset]; Box* val = closure->elts[derefInfo.offset];
Box* boxedName = name.getBox(); Box* boxedName = name.getBox();
if (val != NULL) { if (val != NULL) {
assert(0 &&" add refcounting"); PyDict_SetItem(d, boxedName, val);
d->d[boxedName] = val;
} else { } else {
assert(0 &&" add refcounting"); PyDict_DelItem(d, boxedName);
d->d.erase(boxedName);
} }
} }
......
...@@ -226,6 +226,9 @@ Box* superInit(Box* _self, Box* _type, Box* obj) { ...@@ -226,6 +226,9 @@ Box* superInit(Box* _self, Box* _type, Box* obj) {
if (obj != NULL) if (obj != NULL)
obj_type = superCheck<CXX>(type, obj); obj_type = superCheck<CXX>(type, obj);
assert(!self->type);
assert(!self->obj);
assert(!self->obj_type);
self->type = incref(type); self->type = incref(type);
self->obj = incref(obj); self->obj = incref(obj);
self->obj_type = incref(obj_type); self->obj_type = incref(obj_type);
......
...@@ -1188,6 +1188,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1188,6 +1188,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
Box* initrtn; Box* initrtn;
// If there's a Python-level __init__ function, try calling it. // If there's a Python-level __init__ function, try calling it.
if (init_attr && init_attr->cls == function_cls) { if (init_attr && init_attr->cls == function_cls) {
AUTO_DECREF(made); // In case init throws:
if (rewrite_args) { if (rewrite_args) {
// We are going to rewrite as a call to cls.init: // We are going to rewrite as a call to cls.init:
assert(which_init == MAKES_CLS); assert(which_init == MAKES_CLS);
...@@ -1221,6 +1223,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1221,6 +1223,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
keyword_names); keyword_names);
} }
incref(made); // to cancel out the AUTO_DECREF
if (!initrtn) { if (!initrtn) {
assert(S == CAPI); assert(S == CAPI);
return NULL; return NULL;
...@@ -1254,6 +1258,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1254,6 +1258,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
rearrangeArguments(ParamReceiveSpec(1, 0, true, true), NULL, "", NULL, rewrite_args, rewrite_success, rearrangeArguments(ParamReceiveSpec(1, 0, true, true), NULL, "", NULL, rewrite_args, rewrite_success,
argspec, made, arg2, arg3, args, NULL, keyword_names); argspec, made, arg2, arg3, args, NULL, keyword_names);
} catch (ExcInfo e) { } catch (ExcInfo e) {
Py_DECREF(made);
if (S == CAPI) { if (S == CAPI) {
setCAPIException(e); setCAPIException(e);
return NULL; return NULL;
...@@ -1272,6 +1277,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1272,6 +1277,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
Py_DECREF(arg2); Py_DECREF(arg2);
Py_XDECREF(arg3); Py_XDECREF(arg3);
if (err == -1) { if (err == -1) {
Py_DECREF(made);
if (S == CAPI) if (S == CAPI)
return NULL; return NULL;
else else
......
# expected: reffail
class B(object): class B(object):
def __new__(cls, arg1): def __new__(cls, arg1):
print "B.__new__", arg1 print "B.__new__", arg1
......
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