Commit a4e3cc00 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix 'error return without exception set'

Based on Marius's #865, with some extra checking and a test.
parent c9a9d107
...@@ -2836,9 +2836,10 @@ Box* _callattrEntry(Box* obj, BoxedString* attr, CallattrFlags flags, Box* arg1, ...@@ -2836,9 +2836,10 @@ Box* _callattrEntry(Box* obj, BoxedString* attr, CallattrFlags flags, Box* arg1,
assert(!(S == CAPI && flags.null_on_nonexistent)); assert(!(S == CAPI && flags.null_on_nonexistent));
if (!rewrite_args.out_success) { if (!rewrite_args.out_success) {
rewriter.reset(NULL); rewriter.reset(NULL);
} else if (rtn) { } else if (rtn || S == CAPI) {
rewriter->commitReturning(rewrite_args.out_rtn); rewriter->commitReturning(rewrite_args.out_rtn);
} else if ((S == CAPI && !rtn) || flags.null_on_nonexistent) { } else if (flags.null_on_nonexistent) {
assert(!rewrite_args.out_rtn);
rewriter->commitReturning(rewriter->loadConst(0, rewriter->getReturnDestination())); rewriter->commitReturning(rewriter->loadConst(0, rewriter->getReturnDestination()));
} }
} else { } else {
......
class C(object):
def f(self, n):
if n == 5000:
return
else:
raise Exception()
def f(c, i):
try:
c.f(i)
except Exception:
pass
c = C()
for i in xrange(10000):
f(c, i)
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