Commit 1c3f474d authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix a couple issues and the sys_excinfo test is working

parent 67c85513
......@@ -622,6 +622,12 @@ Value ASTInterpreter::visit_yield(AST_Yield* node) {
}
Value __attribute__((flatten)) ASTInterpreter::visit_stmt(AST_stmt* node) {
if (0) {
printf("%20s % 2d ", source_info->getName().c_str(), current_block->idx);
print_ast(node);
printf("\n");
}
switch (node->type) {
case AST_TYPE::Assert:
return visit_assert((AST_Assert*)node);
......
......@@ -1924,6 +1924,9 @@ public:
if (!caught_all) {
AST_Raise* raise = new AST_Raise();
raise->arg0 = makeName(exc_type_name, AST_TYPE::Load, node->lineno);
raise->arg1 = makeName(exc_value_name, AST_TYPE::Load, node->lineno);
raise->arg2 = makeName(exc_traceback_name, AST_TYPE::Load, node->lineno);
push_back(raise);
curblock->push_back(new AST_Unreachable());
curblock = NULL;
......
# expected: fail
# - wip
# Generators participate in the notional Python stack just like normal function calls do,
# even if we implement them using separate C stacks.
#
# This matters both for tracebacks, and some related things like sys.exc_info which should
# get inherited when we go into a generator
# exc_info gets passed into generators (at both begin and send()) and cleared like normal on the way out:
def f12():
print
print "f12"
print "begin:", sys.exc_info()[0]
def g():
print "start of generator:", sys.exc_info()[0]
yield 1
print "after first yield:", sys.exc_info()[0]
try:
raise KeyError()
except:
pass
print "after KeyError:", sys.exc_info()[0]
yield 2
try:
raise AttributeError()
except:
pass
i = g()
i.next()
try:
1/0
except:
print "after exc:", sys.exc_info()[0]
i.next()
print "after next:", sys.exc_info()[0]
list(i)
f12()
# expected: fail
# - exceptions
# Different ways of nesting exceptions
import sys
......@@ -183,40 +180,6 @@ def f11():
f11()
print sys.exc_info()[0]
# exc_info gets passed into generators (at both begin and send()) and cleared like normal on the way out:
def f12():
print
print "f12"
print "begin:", sys.exc_info()[0]
def g():
print "start of generator:", sys.exc_info()[0]
yield 1
print "after first yield:", sys.exc_info()[0]
try:
raise KeyError()
except:
pass
print "after KeyError:", sys.exc_info()[0]
yield 2
try:
raise AttributeError()
except:
pass
i = g()
i.next()
try:
1/0
except:
print "after exc:", sys.exc_info()[0]
i.next()
print "after next:", sys.exc_info()[0]
list(i)
f12()
# If an exception is thrown+caught in course of exception-matching, we need to still operate on the original exception:
def f13():
print
......@@ -229,6 +192,10 @@ def f13():
print sys.exc_info()[0]
return ZeroDivisionError
print sys.exc_info()[0]
inner()
print sys.exc_info()[0]
# This applies to what goes into exc_info:
try:
1/0
......
......@@ -235,7 +235,7 @@ def run_test(fn, check_stats, run_memcheck):
out_fd, out_fn = tempfile.mkstemp(prefix="received_")
os.fdopen(exp_fd, 'w').write(expected_out)
os.fdopen(out_fd, 'w').write(out)
p = subprocess.Popen(["diff", "-u", "-a", exp_fn, out_fn], stdout=subprocess.PIPE, preexec_fn=set_ulimits)
p = subprocess.Popen(["diff", "--unified=5", "-a", exp_fn, out_fn], stdout=subprocess.PIPE, preexec_fn=set_ulimits)
diff = p.stdout.read()
assert p.wait() in (0, 1)
os.unlink(exp_fn)
......
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