merge with latest cython-devel
authorStefan Behnel <scoder@users.berlios.de>
Fri, 11 Sep 2009 17:20:05 +0000 (19:20 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 11 Sep 2009 17:20:05 +0000 (19:20 +0200)
1  2 
Cython/Compiler/ExprNodes.py
Cython/Compiler/Main.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Symtab.py
tests/errors/nogil.pyx

Simple merge
index 0007691dd3f5cc0a6378b86427c68f06cf51a7ab,804e3221b9d97276b3865e6d3e8fb1ac2981636c..7d1a014e0ef92f4ff766ddf19a56dd8f97743847
@@@ -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.
index 967f38e44f217c0bb1a72e8ad6d0c40645712127,b007d1cf163f5dc0e6db51ba7fab4db9646aec18..429f8415d298e1729e0ace0bff740ac79191f308
@@@ -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()
index 5228581081fa509f396ebe1546d917f18fd72cfd,e1b4524f96f2537fdced27e75d1b4ae6ffe2d4f3..e61bf244cf67d1d434644b8aea426a7217164482
@@@ -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 = []
Simple merge
Simple merge
index 27edc94547eb2652530bdd3c42ea5e649909fe48,a72848d03bb672617ba432123f9600032208c160..d6c3c6d048cc4301466992e67177518829fc4f87
@@@ -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