diff -rc /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/ExprNodes.py /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/ExprNodes.py *** /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/ExprNodes.py Sun Jan 11 16:55:49 2004 --- /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/ExprNodes.py Sun Jan 11 20:16:05 2004 *************** *** 445,451 **** if dst_type.is_pyobject: if not src.type.is_pyobject: src = CoerceToPyTypeNode(src, env) ! if not src.type.subtype_of(dst_type): src = PyTypeTestNode(src, dst_type, env) elif src.type.is_pyobject: src = CoerceFromPyTypeNode(dst_type, src, env) --- 445,452 ---- if dst_type.is_pyobject: if not src.type.is_pyobject: src = CoerceToPyTypeNode(src, env) ! if (not dst_type.is_pysequence ! and not src.type.subtype_of(dst_type)): src = PyTypeTestNode(src, dst_type, env) elif src.type.is_pyobject: src = CoerceFromPyTypeNode(dst_type, src, env) *************** *** 939,945 **** self.base.analyse_types(env) self.index.analyse_types(env) if self.base.type.is_pyobject: ! self.index = self.index.coerce_to_pyobject(env) self.type = PyrexTypes.py_object_type self.is_temp = 1 else: --- 940,951 ---- self.base.analyse_types(env) self.index.analyse_types(env) if self.base.type.is_pyobject: ! if self.base.type.is_pysequence and \ ! not self.index.type.is_pyobject: ! self.index = self.index.coerce_to( ! PyrexTypes.c_int_type, env) ! else: ! self.index = self.index.coerce_to_pyobject(env) self.type = PyrexTypes.py_object_type self.is_temp = 1 else: *************** *** 970,976 **** self.base.result, self.index.result) def generate_result_code(self, code): ! if self.type.is_pyobject: code.putln( "%s = PyObject_GetItem(%s, %s); if (!%s) %s" % ( self.result, --- 976,991 ---- self.base.result, self.index.result) def generate_result_code(self, code): ! if self.base.type.is_pysequence and \ ! not self.index.type.is_pyobject: ! code.putln( ! "%s = PySequence_GetItem(%s, %s); if (!%s) %s" % ( ! self.result, ! self.base.result, ! self.index.result, ! self.result, ! code.error_goto(self.pos))) ! elif self.type.is_pyobject: code.putln( "%s = PyObject_GetItem(%s, %s); if (!%s) %s" % ( self.result, *************** *** 981,987 **** def generate_assignment_code(self, rhs, code): self.generate_subexpr_evaluation_code(code) ! if self.type.is_pyobject: code.putln( "if (PyObject_SetItem(%s, %s, %s) < 0) %s" % ( self.base.result, --- 996,1010 ---- def generate_assignment_code(self, rhs, code): self.generate_subexpr_evaluation_code(code) ! if self.base.type.is_pysequence: ! code.putln( ! "if (PySequence_SetItem(%s, %s, %s) < 0) %s" % ( ! self.base.result, ! self.index.result, ! rhs.result, ! code.error_goto(self.pos))) ! self.generate_subexpr_disposal_code(code) ! elif self.type.is_pyobject: code.putln( "if (PyObject_SetItem(%s, %s, %s) < 0) %s" % ( self.base.result, *************** *** 2998,3001 **** #------------------------------------------------------------------------------------ ! \ No newline at end of file --- 3021,3024 ---- #------------------------------------------------------------------------------------ ! diff -rc /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/Nodes.py /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/Nodes.py *** /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/Nodes.py Sun Jan 11 16:55:49 2004 --- /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/Nodes.py Sun Jan 11 17:08:48 2004 *************** *** 8,14 **** from Errors import error, InternalError import Naming import PyrexTypes ! from PyrexTypes import py_object_type, error_type from Symtab import ModuleScope, LocalScope, \ StructOrUnionScope, PyClassScope, CClassScope import TypeSlots --- 8,14 ---- from Errors import error, InternalError import Naming import PyrexTypes ! from PyrexTypes import py_object_type, error_type, py_sequence_type from Symtab import ModuleScope, LocalScope, \ StructOrUnionScope, PyClassScope, CClassScope import TypeSlots *************** *** 1326,1331 **** --- 1326,1333 ---- error(self.pos, "Unrecognised type modifier combination") elif self.name == "object" and not self.module_path: type = py_object_type + elif self.name == "sequence" and not self.module_path: + type = py_sequence_type elif self.name is None: if self.is_self_arg and env.is_c_class_scope: type = env.parent_type diff -rc /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/Parsing.py /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/Parsing.py *** /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/Parsing.py Sun Jan 11 16:55:49 2004 --- /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/Parsing.py Sun Jan 11 17:04:09 2004 *************** *** 1737,1742 **** --- 1737,1743 ---- def p_module(s, pxd): s.add_type_name("object") + s.add_type_name("sequence") pos = s.position() doc = p_doc_string(s) if pxd: diff -rc /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/PyrexTypes.py /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/PyrexTypes.py *** /usr/local/lib/python2.3/site-packages/OPyrex/Compiler/PyrexTypes.py Sun Jan 11 16:55:49 2004 --- /usr/local/lib/python2.3/site-packages/Pyrex/Compiler/PyrexTypes.py Sun Jan 11 18:09:25 2004 *************** *** 10,15 **** --- 10,16 ---- # Base class for all Pyrex types. # # is_pyobject boolean Is a Python object type + # is_pysequence boolean Is a Python sequence # is_extension_type boolean Is a Python extension type # is_numeric boolean Is a C numeric type # is_int boolean Is a C integer type *************** *** 55,60 **** --- 56,62 ---- # is_pyobject = 0 + is_pysequence = 0 is_extension_type = 0 is_numeric = 0 is_int = 0 *************** *** 126,131 **** --- 128,145 ---- else: return "%s *%s" % (public_decl("PyObject", dll_linkage), entity_code) + class PySequenceType(PyObjectType): + is_pysequence = 1 + + def __str__(self): + return "Python sequence" + + def __repr__(self): + return "PySequenceType" + + def subtype_of(self, other_type): + return (other_type is py_object_type + or self.same_as(other_type)) class PyExtensionType(PyObjectType): # *************** *** 622,627 **** --- 636,642 ---- py_object_type = PyObjectType() + py_sequence_type = PySequenceType() c_void_type = CVoidType() c_void_ptr_type = CPtrType(c_void_type) *************** *** 700,705 **** --- 715,721 ---- (1, 0, "double"): c_double_type, (1, 1, "double"): c_longdouble_type, (1, 0, "object"): py_object_type, + (1, 0, "sequence"): py_sequence_type, } def widest_numeric_type(type1, type2):