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
caac4358
Commit
caac4358
authored
Sep 10, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#344, stop pipeline before code generation in case of errors
parent
a5c7de87
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
11 deletions
+32
-11
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+7
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-6
tests/errors/e_argdefault.pyx
tests/errors/e_argdefault.pyx
+2
-1
tests/errors/e_del.pyx
tests/errors/e_del.pyx
+1
-3
tests/errors/e_del2.pyx
tests/errors/e_del2.pyx
+12
-0
tests/errors/nogil.pyx
tests/errors/nogil.pyx
+1
-1
No files found.
Cython/Compiler/Main.py
View file @
caac4358
...
@@ -34,6 +34,12 @@ def dumptree(t):
...
@@ -34,6 +34,12 @@ def dumptree(t):
print
t
.
dump
()
print
t
.
dump
()
return
t
return
t
def
abort_on_errors
(
node
):
# Stop the pipeline if there are any errors.
if
Errors
.
num_errors
!=
0
:
raise
InternalError
,
"abort"
return
node
class
CompilationData
(
object
):
class
CompilationData
(
object
):
# Bundles the information that is passed from transform to transform.
# Bundles the information that is passed from transform to transform.
# (For now, this is only)
# (For now, this is only)
...
@@ -157,6 +163,7 @@ class Context(object):
...
@@ -157,6 +163,7 @@ class Context(object):
create_parse
(
self
),
create_parse
(
self
),
]
+
self
.
create_pipeline
(
pxd
=
False
,
py
=
py
)
+
[
]
+
self
.
create_pipeline
(
pxd
=
False
,
py
=
py
)
+
[
inject_pxd_code
,
inject_pxd_code
,
abort_on_errors
,
generate_pyx_code
,
generate_pyx_code
,
])
])
...
...
Cython/Compiler/Nodes.py
View file @
caac4358
...
@@ -1006,8 +1006,10 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1006,8 +1006,10 @@ class FuncDefNode(StatNode, BlockNode):
def
analyse_default_values
(
self
,
env
):
def
analyse_default_values
(
self
,
env
):
genv
=
env
.
global_scope
()
genv
=
env
.
global_scope
()
default_seen
=
0
for
arg
in
self
.
args
:
for
arg
in
self
.
args
:
if
arg
.
default
:
if
arg
.
default
:
default_seen
=
1
if
arg
.
is_generic
:
if
arg
.
is_generic
:
if
not
hasattr
(
arg
,
'default_entry'
):
if
not
hasattr
(
arg
,
'default_entry'
):
arg
.
default
.
analyse_types
(
env
)
arg
.
default
.
analyse_types
(
env
)
...
@@ -1028,6 +1030,10 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1028,6 +1030,10 @@ class FuncDefNode(StatNode, BlockNode):
error
(
arg
.
pos
,
error
(
arg
.
pos
,
"This argument cannot have a default value"
)
"This argument cannot have a default value"
)
arg
.
default
=
None
arg
.
default
=
None
elif
arg
.
kw_only
:
default_seen
=
1
elif
default_seen
:
error
(
arg
.
pos
,
"Non-default argument following default argument"
)
def
need_gil_acquisition
(
self
,
lenv
):
def
need_gil_acquisition
(
self
,
lenv
):
return
0
return
0
...
@@ -1106,7 +1112,7 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1106,7 +1112,7 @@ class FuncDefNode(StatNode, BlockNode):
# ----- Extern library function declarations
# ----- Extern library function declarations
lenv
.
generate_library_function_declarations
(
code
)
lenv
.
generate_library_function_declarations
(
code
)
# ----- GIL acquisition
# ----- GIL acquisition
acquire_gil
=
self
.
need_gil_acquisition
(
lenv
)
acquire_gil
=
self
.
acquire_gil
if
acquire_gil
:
if
acquire_gil
:
env
.
use_utility_code
(
force_init_threads_utility_code
)
env
.
use_utility_code
(
force_init_threads_utility_code
)
code
.
putln
(
"PyGILState_STATE _save = PyGILState_Ensure();"
)
code
.
putln
(
"PyGILState_STATE _save = PyGILState_Ensure();"
)
...
@@ -1446,6 +1452,7 @@ class CFuncDefNode(FuncDefNode):
...
@@ -1446,6 +1452,7 @@ class CFuncDefNode(FuncDefNode):
self
.
analyse_default_values
(
env
)
self
.
analyse_default_values
(
env
)
if
self
.
py_func
is
not
None
:
if
self
.
py_func
is
not
None
:
self
.
py_func
.
analyse_expressions
(
env
)
self
.
py_func
.
analyse_expressions
(
env
)
self
.
acquire_gil
=
self
.
need_gil_acquisition
(
self
.
local_scope
)
def
generate_function_header
(
self
,
code
,
with_pymethdef
,
with_opt_args
=
1
,
with_dispatch
=
1
,
cname
=
None
):
def
generate_function_header
(
self
,
code
,
with_pymethdef
,
with_opt_args
=
1
,
with_dispatch
=
1
,
cname
=
None
):
arg_decls
=
[]
arg_decls
=
[]
...
@@ -1869,6 +1876,7 @@ class DefNode(FuncDefNode):
...
@@ -1869,6 +1876,7 @@ class DefNode(FuncDefNode):
self
.
analyse_default_values
(
env
)
self
.
analyse_default_values
(
env
)
if
env
.
is_py_class_scope
:
if
env
.
is_py_class_scope
:
self
.
synthesize_assignment_node
(
env
)
self
.
synthesize_assignment_node
(
env
)
self
.
acquire_gil
=
0
def
synthesize_assignment_node
(
self
,
env
):
def
synthesize_assignment_node
(
self
,
env
):
import
ExprNodes
import
ExprNodes
...
@@ -1971,12 +1979,10 @@ class DefNode(FuncDefNode):
...
@@ -1971,12 +1979,10 @@ class DefNode(FuncDefNode):
else
:
else
:
positional_args
=
[]
positional_args
=
[]
kw_only_args
=
[]
kw_only_args
=
[]
default_seen
=
0
for
arg
in
self
.
args
:
for
arg
in
self
.
args
:
arg_entry
=
arg
.
entry
arg_entry
=
arg
.
entry
if
arg
.
is_generic
:
if
arg
.
is_generic
:
if
arg
.
default
:
if
arg
.
default
:
default_seen
=
1
if
not
arg
.
is_self_arg
:
if
not
arg
.
is_self_arg
:
if
arg
.
kw_only
:
if
arg
.
kw_only
:
kw_only_args
.
append
(
arg
)
kw_only_args
.
append
(
arg
)
...
@@ -1984,9 +1990,6 @@ class DefNode(FuncDefNode):
...
@@ -1984,9 +1990,6 @@ class DefNode(FuncDefNode):
positional_args
.
append
(
arg
)
positional_args
.
append
(
arg
)
elif
arg
.
kw_only
:
elif
arg
.
kw_only
:
kw_only_args
.
append
(
arg
)
kw_only_args
.
append
(
arg
)
default_seen
=
1
elif
default_seen
:
error
(
arg
.
pos
,
"Non-default argument following default argument"
)
elif
not
arg
.
is_self_arg
:
elif
not
arg
.
is_self_arg
:
positional_args
.
append
(
arg
)
positional_args
.
append
(
arg
)
...
...
tests/errors/e_argdefault.pyx
View file @
caac4358
...
@@ -11,6 +11,7 @@ cdef class Grail:
...
@@ -11,6 +11,7 @@ cdef class Grail:
_ERRORS
=
u"""
_ERRORS
=
u"""
1:10: Non-default argument follows default argument
1:10: Non-default argument follows default argument
9:16: This argument cannot have a default value
1:36: Non-default argument following default argument
4:23: Non-default argument following default argument
4:23: Non-default argument following default argument
9:16: This argument cannot have a default value
"""
"""
tests/errors/e_del.pyx
View file @
caac4358
...
@@ -8,13 +8,11 @@ def f(a):
...
@@ -8,13 +8,11 @@ def f(a):
del
f
()
# error
del
f
()
# error
del
i
# error: deletion of non-Python object
del
i
# error: deletion of non-Python object
del
j
# error: deletion of non-Python object
del
j
# error: deletion of non-Python object
del
a
# error: deletion of local name not supported
del
x
[
i
]
# error: deletion of non-Python object
del
x
[
i
]
# error: deletion of non-Python object
del
s
.
m
# error: deletion of non-Python object
del
s
.
m
# error: deletion of non-Python object
_ERRORS
=
u"""
_ERRORS
=
u"""
8:6: Cannot assign to or delete this
8:6: Cannot assign to or delete this
9:45: Deletion of non-Python object
9:45: Deletion of non-Python object
11:6: Deletion of non-Python object
12:6: Deletion of non-Python object
12:6: Deletion of non-Python object
13:6: Deletion of non-Python object
11:52: Deletion of local or C global name not supported
"""
"""
tests/errors/e_del2.pyx
0 → 100644
View file @
caac4358
# Errors reported during code generation.
cdef
int
i
def
f
(
a
):
del
a
# error: deletion of local name not supported
del
i
# error: deletion of local name not supported
_ERRORS
=
u"""
6:52: Deletion of local or C global name not supported
7:52: Deletion of local or C global name not supported
"""
tests/errors/nogil.pyx
View file @
caac4358
...
@@ -103,7 +103,7 @@ _ERRORS = u"""
...
@@ -103,7 +103,7 @@ _ERRORS = u"""
38:11: Accessing Python attribute not allowed without gil
38:11: Accessing Python attribute not allowed without gil
39: 9: Constructing Python tuple not allowed without gil
39: 9: Constructing Python tuple not allowed without gil
40: 8: Constructing Python list not allowed without gil
40: 8: Constructing Python list not allowed without gil
41: 8: Constructing Python dict not allowed without gil
#
41: 8: Constructing Python dict not allowed without gil
42:12: Truth-testing Python object not allowed without gil
42:12: Truth-testing Python object not allowed without gil
43:13: Python type test not allowed without gil
43:13: Python type test not allowed without gil
#44: 4: Converting to Python object not allowed without gil
#44: 4: Converting to Python object not allowed without gil
...
...
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