print t.dump()
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):
# Bundles the information that is passed from transform to transform.
# (For now, this is only)
create_parse(self),
] + self.create_pipeline(pxd=False, py=py) + [
inject_pxd_code,
+ abort_on_errors,
generate_pyx_code,
])
def analyse_default_values(self, env):
genv = env.global_scope()
+ default_seen = 0
for arg in self.args:
if arg.default:
+ default_seen = 1
if arg.is_generic:
if not hasattr(arg, 'default_entry'):
arg.default.analyse_types(env)
error(arg.pos,
"This argument cannot have a default value")
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):
return 0
# ----- Extern library function declarations
lenv.generate_library_function_declarations(code)
# ----- GIL acquisition
- acquire_gil = self.need_gil_acquisition(lenv)
+ acquire_gil = self.acquire_gil
if acquire_gil:
env.use_utility_code(force_init_threads_utility_code)
code.putln("PyGILState_STATE _save = PyGILState_Ensure();")
self.analyse_default_values(env)
if self.py_func is not None:
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):
arg_decls = []
self.analyse_default_values(env)
if env.is_py_class_scope:
self.synthesize_assignment_node(env)
+ self.acquire_gil = 0
def synthesize_assignment_node(self, env):
import ExprNodes
else:
positional_args = []
kw_only_args = []
- default_seen = 0
for arg in self.args:
arg_entry = arg.entry
if arg.is_generic:
if arg.default:
- default_seen = 1
if not arg.is_self_arg:
if arg.kw_only:
kw_only_args.append(arg)
positional_args.append(arg)
elif arg.kw_only:
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:
positional_args.append(arg)
_ERRORS = u"""
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
+9:16: This argument cannot have a default value
"""
del f() # error
del i # 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 s.m # error: deletion of non-Python object
_ERRORS = u"""
8:6: Cannot assign to or delete this
9:45: Deletion of non-Python object
+11: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
"""
--- /dev/null
+# 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
+"""
38:11: Accessing Python attribute not allowed without gil
39: 9: Constructing Python tuple 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
43:13: Python type test not allowed without gil
#44: 4: Converting to Python object not allowed without gil