Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
bbf293be
Commit
bbf293be
authored
May 09, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in latest cython-devel
parents
47aeb5aa
f02ddb4e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
3 deletions
+182
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+18
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-1
tests/run/cpp_exceptions.pyx
tests/run/cpp_exceptions.pyx
+48
-0
tests/run/cpp_exceptions_helper.h
tests/run/cpp_exceptions_helper.h
+10
-0
tests/run/for_in_break_continue_T533.pyx
tests/run/for_in_break_continue_T533.pyx
+40
-0
tests/run/pointers.pyx
tests/run/pointers.pyx
+62
-0
No files found.
Cython/Compiler/Nodes.py
View file @
bbf293be
...
...
@@ -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
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
bbf293be
...
...
@@ -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
):
...
...
Cython/Compiler/Symtab.py
View file @
bbf293be
...
...
@@ -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
...
...
tests/run/cpp_exceptions.pyx
View file @
bbf293be
...
...
@@ -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
tests/run/cpp_exceptions_helper.h
View file @
bbf293be
...
...
@@ -13,3 +13,13 @@ int raise_index(int fire) {
}
return
0
;
}
class
Foo
{
public:
int
bar
(
int
fire
)
{
if
(
fire
)
{
throw
1
;
}
return
0
;
}
};
tests/run/for_in_break_continue_T533.pyx
0 → 100644
View file @
bbf293be
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
tests/run/pointers.pyx
0 → 100644
View file @
bbf293be
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment