Commit bbf293be authored by Stefan Behnel's avatar Stefan Behnel

merged in latest cython-devel

parents 47aeb5aa f02ddb4e
......@@ -4290,11 +4290,28 @@ class ForInStatNode(LoopNode, StatNode):
"}")
break_label = code.break_label
code.set_loop_labels(old_loop_labels)
if self.else_clause:
# in nested loops, the 'else' block can contain a
# 'continue' statement for the outer loop, but we may need
# to generate cleanup code before taking that path, so we
# intercept it here
orig_continue_label = code.continue_label
code.continue_label = code.new_label('outer_continue')
code.putln("/*else*/ {")
self.else_clause.generate_execution_code(code)
code.putln("}")
code.put_label(break_label)
if code.label_used(code.continue_label):
code.put_goto(break_label)
code.put_label(code.continue_label)
self.iterator.generate_disposal_code(code)
code.put_goto(orig_continue_label)
code.set_loop_labels(old_loop_labels)
if code.label_used(break_label):
code.put_label(break_label)
self.iterator.release_counter_temp(code)
self.iterator.generate_disposal_code(code)
self.iterator.free_temps(code)
......
......@@ -2431,7 +2431,7 @@ def independent_spanning_type(type1, type2):
return py_object_type
span_type = _spanning_type(type1, type2)
if span_type is None:
return PyrexTypes.error_type
return error_type
return span_type
def spanning_type(type1, type2):
......
......@@ -1661,7 +1661,9 @@ class CppClassScope(Scope):
e.pos,
e.cname)
return scope
def add_include_file(self, filename):
self.outer_scope.add_include_file(filename)
class PropertyScope(Scope):
# Scope holding the __get__, __set__ and __del__ methods for
......
......@@ -10,6 +10,12 @@ cdef extern from "cpp_exceptions_helper.h":
cdef int raise_index_value "raise_index"(bint fire) except +ValueError
cdef int raise_index_custom "raise_index"(bint fire) except +raise_py_error
cdef cppclass Foo:
int bar_raw "bar"(bint fire) except +
int bar_value "bar"(bint fire) except +ValueError
int bar_custom "bar"(bint fire) except +raise_py_error
def test_int_raw(bint fire):
"""
>>> test_int_raw(False)
......@@ -69,3 +75,45 @@ def test_index_custom(bint fire):
TypeError: custom
"""
raise_index_custom(fire)
def test_cppclass_method_raw(bint fire):
"""
>>> test_cppclass_method_raw(False)
>>> test_cppclass_method_raw(True)
Traceback (most recent call last):
...
RuntimeError: Unknown exception
"""
foo = new Foo()
try:
foo.bar_raw(fire)
finally:
del foo
def test_cppclass_method_value(bint fire):
"""
>>> test_cppclass_method_value(False)
>>> test_cppclass_method_value(True)
Traceback (most recent call last):
...
ValueError
"""
foo = new Foo()
try:
foo.bar_value(fire)
finally:
del foo
def test_cppclass_method_custom(bint fire):
"""
>>> test_cppclass_method_custom(False)
>>> test_cppclass_method_custom(True)
Traceback (most recent call last):
...
TypeError: custom
"""
foo = new Foo()
try:
foo.bar_custom(fire)
finally:
del foo
......@@ -13,3 +13,13 @@ int raise_index(int fire) {
}
return 0;
}
class Foo {
public:
int bar(int fire) {
if (fire) {
throw 1;
}
return 0;
}
};
def for_in():
"""
>>> for_in()
CONTINUE -1
CONTINUE 4
BREAK 6
6
"""
i = -1
for L in [[], range(5), range(10)]:
for i in L:
if i > 5:
break
else:
print "CONTINUE", i
continue
print "BREAK", i
break
return i
def for_from():
"""
>>> for_from()
CONTINUE 0
CONTINUE 5
BREAK 6
6
"""
i = -1
for L in [[], range(5), range(10)]:
for i from 0 <= i < len(L):
if i > 5:
break
else:
print "CONTINUE", i
continue
print "BREAK", i
break
return i
cdef char* c_string = b'abcdefg'
cdef void* void_ptr = c_string
cdef int i = 42
cdef int* int_ptr = &i
cdef float x = 42.2
cdef float* float_ptr = &x
def compare():
"""
>>> compare()
True
True
True
False
False
True
True
"""
print c_string == c_string
print c_string == void_ptr
print c_string is void_ptr
print c_string != void_ptr
print c_string is not void_ptr
print void_ptr != int_ptr
print void_ptr != float_ptr
def if_tests():
"""
>>> if_tests()
True
True
"""
if c_string == void_ptr:
print True
if c_string != void_ptr:
print False
if int_ptr != void_ptr:
print True
def bool_binop():
"""
>>> bool_binop()
True
"""
if c_string == void_ptr and c_string == c_string and int_ptr != void_ptr and void_ptr != float_ptr:
print True
def bool_binop_truth(int x):
"""
>>> bool_binop_truth(1)
True
True
>>> bool_binop_truth(0)
True
"""
if c_string and void_ptr and int_ptr and (c_string == c_string or int_ptr != void_ptr):
print True
if c_string and x or not (void_ptr or int_ptr and float_ptr) or x:
print True
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