Commit ec8adc6f authored by Kevin Modzelewski's avatar Kevin Modzelewski

More ref fixes

parent abaede1e
......@@ -3372,6 +3372,7 @@ static Box* tppProxyToTpCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSp
rewrite_args->out_rtn = rewrite_args->rewriter->call(true, (void*)self->cls->tp_call, rewrite_args->obj,
rewrite_args->arg1, rewrite_args->arg2);
rewrite_args->out_rtn->setType(RefType::OWNED);
if (S == CXX)
rewrite_args->rewriter->checkAndThrowCAPIException(rewrite_args->out_rtn);
rewrite_args->out_success = true;
......
......@@ -236,7 +236,6 @@ void ASTInterpreter::setFrameInfo(const FrameInfo* frame_info) {
}
void ASTInterpreter::setGlobals(Box* globals) {
assert(0 && "Check refcounting (of callers)");
assert(!this->frame_info.globals);
this->frame_info.globals = incref(globals);
}
......@@ -892,6 +891,7 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
int level = static_cast<AST_Num*>(node->args[0])->n_int;
Value froms = visit_expr(node->args[1]);
AUTO_DECREF(froms.o);
auto ast_str = ast_cast<AST_Str>(node->args[2]);
assert(ast_str->str_type == AST_Str::STR);
const std::string& module_name = ast_str->str_data;
......
......@@ -493,7 +493,7 @@ Box* delattrFunc(Box* obj, Box* _str) {
return None;
}
static Box* getattrFuncHelper(Box* return_val, Box* obj, BoxedString* str, Box* default_val) noexcept {
static Box* getattrFuncHelper(STOLEN(Box*) return_val, Box* obj, BoxedString* str, Box* default_val) noexcept {
assert(PyString_Check(str));
if (return_val)
......@@ -506,7 +506,7 @@ static Box* getattrFuncHelper(Box* return_val, Box* obj, BoxedString* str, Box*
if (default_val) {
if (exc)
PyErr_Clear();
return default_val;
return incref(default_val);
}
if (!exc)
raiseAttributeErrorCapi(obj, str->s());
......@@ -527,6 +527,10 @@ Box* getattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
Box* _str = arg2;
Box* default_value = arg3;
AUTO_DECREF(obj);
AUTO_DECREF(_str);
AUTO_XDECREF(default_value);
if (rewrite_args) {
// We need to make sure that the attribute string will be the same.
// Even though the passed string might not be the exact attribute name
......@@ -549,6 +553,7 @@ Box* getattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
_str = coerceUnicodeToStr<S>(_str);
if (S == CAPI && !_str)
return NULL;
AUTO_DECREF(_str);
if (!PyString_Check(_str)) {
if (S == CAPI) {
......@@ -594,8 +599,10 @@ Box* getattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
if (rewrite_args) {
assert(PyString_CHECK_INTERNED(str) == SSTATE_INTERNED_IMMORTAL);
RewriterVar* r_str = rewrite_args->rewriter->loadConst((intptr_t)str, Location::forArg(2));
RewriterVar* final_rtn = rewrite_args->rewriter->call(false, (void*)getattrFuncHelper, r_rtn,
rewrite_args->arg1, r_str, rewrite_args->arg3);
RewriterVar* final_rtn
= rewrite_args->rewriter->call(false, (void*)getattrFuncHelper, r_rtn, rewrite_args->arg1, r_str,
rewrite_args->arg3)->setType(RefType::OWNED);
r_rtn->refConsumed();
if (S == CXX)
rewrite_args->rewriter->checkAndThrowCAPIException(final_rtn);
......
......@@ -82,7 +82,10 @@ Box* dictCopy(BoxedDict* self) {
raiseExcHelper(TypeError, "descriptor 'copy' requires a 'dict' object but received a '%s'", getTypeName(self));
BoxedDict* r = new BoxedDict();
assert(0 && "check refcounting");
for (auto&& p : self->d) {
Py_INCREF(p.first.value);
Py_INCREF(p.second);
}
r->d = self->d;
return r;
}
......
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