from ParseTreeTransforms import AnalyseDeclarationsTransform, AnalyseExpressionsTransform
from ParseTreeTransforms import CreateClosureClasses, MarkClosureVisitor, DecoratorTransform
from ParseTreeTransforms import InterpretCompilerDirectives, TransformBuiltinMethods
- from ParseTreeTransforms import AlignFunctionDefinitions
+ from ParseTreeTransforms import AlignFunctionDefinitions, GilCheck
from AutoDocTransforms import EmbedSignature
from Optimize import FlattenInListTransform, SwitchTransform, IterationTransform
- from Optimize import FlattenBuiltinTypeCreation, ConstantFolding, FinalOptimizePhase
+ from Optimize import OptimizeBuiltinCalls, ConstantFolding, FinalOptimizePhase
from Buffer import IntroduceBufferAuxiliaryVars
- from ModuleNode import check_c_declarations
+ from ModuleNode import check_c_declarations, check_c_declarations_pxd
# Temporary hack that can be used to ensure that all result_code's
# are generated at code generation time.
code.put_goto(code.return_label)
code.put_label(code.error_label)
- code.put_var_xdecrefs(env.temp_entries)
for cname, type in code.funcstate.all_managed_temps():
code.put_xdecref(cname, type)
- code.putln('__Pyx_AddTraceback("%s");' % env.qualified_name)
+ code.putln('if (%s) {' % env.module_cname)
+ code.putln('__Pyx_AddTraceback("init %s");' % env.qualified_name)
env.use_utility_code(Nodes.traceback_utility_code)
code.put_decref_clear(env.module_cname, py_object_type, nanny=False)
+ code.putln('} else if (!PyErr_Occurred()) {')
+ code.putln('PyErr_SetString(PyExc_ImportError, "init %s");' % env.qualified_name)
+ code.putln('}')
code.put_label(code.return_label)
code.put_finish_refcount_context()
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)
- arg.default = arg.default.coerce_to(arg.type, genv)
- if arg.default.is_literal:
- arg.default_entry = arg.default
- arg.default_result_code = arg.default.calculate_result_code()
- if arg.default.type != arg.type and not arg.type.is_int:
- arg.default_result_code = arg.type.cast_code(arg.default_result_code)
- else:
- arg.default.allocate_temps(genv)
- arg.default_entry = genv.add_default_value(arg.type)
- if arg.type.is_pyobject:
- arg.default_entry.init = 0
- arg.default_entry.used = 1
- arg.default_result_code = arg.default_entry.cname
+ arg.default.analyse_types(env)
+ arg.default = arg.default.coerce_to(arg.type, genv)
else:
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
def analyse_expressions(self, env):
self.local_scope.directives = env.directives
- self.analyse_default_values(env)
if self.py_func is not None:
+ # this will also analyse the default values
self.py_func.analyse_expressions(env)
+ else:
+ self.analyse_default_values(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 = []
37:15: Converting to Python object not allowed without gil
37:17: Converting to Python object not allowed without gil
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
+ 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
45:10: Operation not allowed without gil
-46: 8: Operation not allowed without gil
+46:8: Operation not allowed without gil
47:10: Assignment of Python object not allowed without gil
47:14: Assignment of Python object not allowed without gil
-48: 9: Assignment of Python object not allowed without gil
+48:9: Assignment of Python object not allowed without gil
48:13: Assignment of Python object not allowed without gil
48:16: Creating temporary Python reference not allowed without gil
48:19: Creating temporary Python reference not allowed without gil