merge
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 7 Jan 2009 13:20:01 +0000 (14:20 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 7 Jan 2009 13:20:01 +0000 (14:20 +0100)
1  2 
Cython/Compiler/Buffer.py
Cython/Compiler/Code.py
Cython/Compiler/DebugFlags.py
Cython/Compiler/ExprNodes.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Visitor.py
runtests.py
tests/run/bufaccess.pyx

Simple merge
Simple merge
index aaa040b93f69263ba9cf7c6ef3a1da21162add36,958ce269752a935a45e9e388b94b7a6fdf0b7cfe..b5c27369e01dd31ecbf087fef174c0c50216a923
@@@ -2,4 -2,4 +2,5 @@@ debug_disposal_code = 
  debug_temp_alloc = 0
  debug_coercion = 0
  
 -debug_refnanny = 1
 +debug_temp_code_comments = 1
++
index 1043a64c2bc29dbec5906e00b461d8dda8de43ba,5f832cdc3a0a90b59a86df4bd77c3768711b65cd..4673dcf81a60fef638af538a176d11c2d38137db
@@@ -1016,9 -903,10 +1016,10 @@@ class LongNode(AtomicNewTempExprNode)
                  self.result(),
                  self.value,
                  code.error_goto_if_null(self.result(), self.pos)))
+         code.put_gotref(self.result())
  
  
 -class ImagNode(AtomicExprNode):
 +class ImagNode(AtomicNewTempExprNode):
      #  Imaginary number literal
      #
      #  value   float    imaginary part
@@@ -1442,14 -1321,11 +1450,15 @@@ class ImportNode(ExprNode)
                  self.module_name.py_result(),
                  name_list_code,
                  code.error_goto_if_null(self.result(), self.pos)))
+         code.put_gotref(self.result())
  
  
 -class IteratorNode(ExprNode):
 +class IteratorNode(NewTempExprNode):
      #  Used as part of for statement implementation.
 +    #
 +    #  allocate_counter_temp/release_counter_temp needs to be called
 +    #  by parent (ForInStatNode)
 +    #
      #  Implements result = iter(sequence)
      #
      #  sequence   ExprNode
                  self.sequence.py_result(),
                  self.result()))
          code.putln("} else {")
 -        code.putln("%s = -1; %s = PyObject_GetIter(%s); %s" % (
 -                self.counter.result(),
 -                self.result(),
 -                self.sequence.py_result(),
 -                code.error_goto_if_null(self.result(), self.pos)))
 -        code.put_gotref(self.result())
 +        if is_builtin_sequence:
 +            code.putln(
 +                'PyErr_SetString(PyExc_TypeError, "\'NoneType\' object is not iterable"); %s' %
 +                code.error_goto(self.pos))
 +        else:
 +            code.putln("%s = -1; %s = PyObject_GetIter(%s); %s" % (
 +                    self.counter_cname,
 +                    self.result(),
 +                    self.sequence.py_result(),
 +                    code.error_goto_if_null(self.result(), self.pos)))
++            code.put_gotref(self.result())
          code.putln("}")
  
  
@@@ -2158,9 -1895,10 +2171,10 @@@ class SliceNode(ExprNode)
                  self.stop.py_result(), 
                  self.step.py_result(),
                  code.error_goto_if_null(self.result(), self.pos)))
+         code.put_gotref(self.result())
  
  
 -class CallNode(ExprNode):
 +class CallNode(NewTempExprNode):
      def gil_check(self, env):
          # Make sure we're not in a nogil environment
          if env.nogil:
@@@ -2990,8 -2715,10 +3012,9 @@@ class SequenceNode(NewTempExprNode)
                      item.result(),
                      typecast(item.ctype(), py_object_type, unpack_code),
                      code.error_goto_if_null(item.result(), self.pos)))
+             code.put_gotref(item.result())
              value_node = self.coerced_unpacked_items[i]
              value_node.generate_evaluation_code(code)
 -            self.args[i].generate_assignment_code(value_node, code)
          code.put_error_if_neg(self.pos, 
              "__Pyx_EndUnpack(%s)" % (
                  self.iterator.py_result()))
@@@ -3519,9 -3149,9 +3548,9 @@@ class UnboundMethodNode(ExprNode)
                  self.function.py_result(),
                  self.class_cname,
                  code.error_goto_if_null(self.result(), self.pos)))
+         code.put_gotref(self.result())
  
 -class PyCFunctionNode(AtomicExprNode):
 +class PyCFunctionNode(AtomicNewTempExprNode):
      #  Helper class used in the implementation of Python
      #  class definitions. Constructs a PyCFunction object
      #  from a PyMethodDef struct.
Simple merge
index 3bdeeae7f5083a2b01d28f0fd2242d6d70e1c934,4592cf47c6d74784ccb90b0e1cff8bc5679c5e2f..38ac2cca1ea65e7117f4622057974fbe650a825a
@@@ -3047,11 -2989,10 +3067,12 @@@ class InPlaceAssignmentNode(AssignmentN
                      self.rhs.py_result(),
                      extra,
                      code.error_goto_if_null(self.result_value.py_result(), self.pos)))
+             code.put_gotref(self.result_value.result())
              self.result_value.generate_evaluation_code(code) # May be a type check...
              self.rhs.generate_disposal_code(code)
 +            self.rhs.free_temps(code)
              self.dup.generate_disposal_code(code)
 +            self.dup.free_temps(code)
              self.lhs.generate_assignment_code(self.result_value, code)
          else: 
              c_op = self.operator
@@@ -4005,10 -3930,13 +4028,15 @@@ class TryExceptStatNode(StatNode)
          for var in Naming.exc_save_vars:
              code.put_xdecref_clear(var, py_object_type)
          code.put_goto(try_end_label)
+         if code.label_used(try_return_label):
+             code.put_label(try_return_label)
+             for var in Naming.exc_save_vars:
+                 code.put_xdecref_clear(var, py_object_type)
+             code.put_goto(old_return_label)
          code.put_label(our_error_label)
          code.put_var_xdecrefs_clear(self.cleanup_list)
 +        for temp_name, type in temps_to_clean_up:
 +            code.put_xdecref_clear(temp_name, type)
          for except_clause in self.except_clauses:
              except_clause.generate_handling_code(code, except_end_label)
  
@@@ -4551,9 -4472,9 +4579,10 @@@ class FromImportStatNode(StatNode)
                      self.module.py_result(),
                      cname,
                      code.error_goto_if_null(self.item.result(), self.pos)))
+             code.put_gotref(self.item.result())
              target.generate_assignment_code(self.item, code)
          self.module.generate_disposal_code(code)
 +        self.module.free_temps(code)
  
  
  
Simple merge
index 50856a3fabca59c5cb193bc3aae71045bf040b5e,0ad6b0de542076d1e842bf2f14c01a7a6a300168..ad5b33ab93df0846dc315da11429d53b7bf3ff2e
@@@ -26,19 -25,19 +26,19 @@@ class BasicVisitor(object)
              # Must resolve, try entire hierarchy
              pattern = "visit_%s"
              mro = inspect.getmro(cls)
+             handler_method = None
              for mro_cls in mro:
-                 try:
+                 if hasattr(self, pattern % mro_cls.__name__):
                      handler_method = getattr(self, pattern % mro_cls.__name__)
                      break
-                 except AttributeError:
-                     pass
-             else:
+             if handler_method is None:
                  print type(self), type(obj)
 -                if hasattr(self, 'access_path'):
 +                if hasattr(self, 'access_path') and self.access_path:
                      print self.access_path
-                     print self.access_path[-1][0].pos
-                     print self.access_path[-1][0].__dict__
-                 raise RuntimeError("Visitor does not accept object: %s" % (obj,))
+                     if self.access_path:
+                         print self.access_path[-1][0].pos
+                         print self.access_path[-1][0].__dict__
+                 raise RuntimeError("Visitor does not accept object: %s" % obj)
              #print "Caching " + cls.__name__
              self.dispatch_table[cls] = handler_method
          return handler_method(obj)
diff --cc runtests.py
Simple merge
Simple merge