From: Stefan Behnel Date: Fri, 11 Sep 2009 17:20:05 +0000 (+0200) Subject: merge with latest cython-devel X-Git-Tag: 0.12.alpha0~218 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=36c54ddae71a09ea3047d8c943191040db1ecb07;p=cython.git merge with latest cython-devel --- 36c54ddae71a09ea3047d8c943191040db1ecb07 diff --cc Cython/Compiler/Main.py index 0007691d,804e3221..7d1a014e --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@@ -81,12 -86,12 +87,12 @@@ class Context(object) 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. diff --cc Cython/Compiler/ModuleNode.py index 967f38e4,b007d1cf..429f8415 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@@ -1697,11 -1714,16 +1704,15 @@@ class ModuleNode(Nodes.Node, Nodes.Bloc 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() diff --cc Cython/Compiler/Nodes.py index 52285810,e1b4524f..e61bf244 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@@ -983,16 -1006,35 +983,22 @@@ class FuncDefNode(StatNode, BlockNode) 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 @@@ -1398,11 -1448,11 +1404,12 @@@ class CFuncDefNode(FuncDefNode) 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 = [] diff --cc tests/errors/nogil.pyx index 27edc945,a72848d0..d6c3c6d0 --- a/tests/errors/nogil.pyx +++ b/tests/errors/nogil.pyx @@@ -109,16 -101,17 +109,16 @@@ _ERRORS = u"" 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