Author: ArcRiley
Date: 2009-01-02 11:23:47 -0500 (Fri, 02 Jan 2009)
New Revision: 1407

Modified:
   trunk/concordance/src/Core.c
Log:
  * replaced depreciated conCore_setattr with conCore_setattro
  * fixed conCore_new so inheritance works properly


Modified: trunk/concordance/src/Core.c
===================================================================
--- trunk/concordance/src/Core.c        2009-01-02 15:34:30 UTC (rev 1406)
+++ trunk/concordance/src/Core.c        2009-01-02 16:23:47 UTC (rev 1407)
@@ -25,16 +25,17 @@
 /* 
 
 cdef class Core :                                                         */
-  char conCore_Doc[] = "Test";
+  static char conCore_Doc[] = "Test";
 
-  PyObject*
-  conCore_new(PyObject* self, PyObject* args) {
-    conCoreObject* new;
-    new = PyObject_New(conCoreObject, &conCore_Type);
-    if (new != NULL) {
-      new->attrs = NULL;
+  static PyObject*
+  conCore_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+    conCoreObject* self;
+    self = (conCoreObject*) type->tp_alloc(type, 0);
+    if (self) {
+      self->attrs = NULL;
+      return (PyObject*) self;
     }
-    return (PyObject*) new;
+    return NULL;
   }
 
   static void
@@ -55,22 +56,26 @@
     return PyObject_GenericGetAttr((PyObject* )self, name);
   }
 
-  static int
-  conCore_setattr(conCoreObject* self, char *name, PyObject* v) {
+  static PyObject*
+  conCore_setattro(conCoreObject* self, PyObject* name, PyObject* value) {
     if (self->attrs == NULL) {
       self->attrs = PyDict_New();
-      if (self->attrs == NULL)
-        return -1;
+      if (self->attrs == NULL) {
+        PyErr_SetString(PyExc_AttributeError,
+                        "error creating attribute dict");
+        return NULL;
+      }
     }
-    if (v == NULL) {
-      int rv = PyDict_DelItemString(self->attrs, name);
-      if (rv < 0)
+    if (value == NULL) {
+      int rv = PyDict_DelItem(self->attrs, name);
+      if (rv < 0) {
         PyErr_SetString(PyExc_AttributeError,
                         "delete non-existing attribute");
-      return rv;
+        return NULL;
+      }      
     }
     else
-      return PyDict_SetItemString(self->attrs, name, v);
+      return (PyObject*) PyDict_SetItem(self->attrs, name, value);
   }
 
   static PyObject*
@@ -98,7 +103,7 @@
     (destructor) conCore_dealloc,      /*tp_dealloc*/
     0,                                 /*tp_print*/
     (getattrfunc) 0,                   /*tp_getattr*/
-    (setattrfunc) conCore_setattr,     /*tp_setattr*/
+    (setattrfunc) 0,                   /*tp_setattr*/
     0,                                 /*tp_compare*/
     0,                                 /*tp_repr*/
     0,                                 /*tp_as_number*/
@@ -108,11 +113,11 @@
     0,                                 /*tp_call*/
     0,                                 /*tp_str*/
     (getattrofunc) conCore_getattro,   /*tp_getattro*/
-    0,                                 /*tp_setattro*/
+    (setattrofunc) conCore_setattro,   /*tp_setattro*/
     0,                                 /*tp_as_buffer*/
     Py_TPFLAGS_DEFAULT |               /*tp_flags*/ 
     Py_TPFLAGS_BASETYPE,
-    0,                                 /*tp_doc*/
+    conCore_Doc,                       /*tp_doc*/
     0,                                 /*tp_traverse*/
     0,                                 /*tp_clear*/
     0,                                 /*tp_richcompare*/
@@ -129,7 +134,7 @@
     0,                                 /*tp_dictoffset*/
     0,                                 /*tp_init*/
     0,                                 /*tp_alloc*/
-    (newfunc) conCore_new,             /*tp_new*/
+    conCore_new,                       /*tp_new*/
     0,                                 /*tp_free*/
     0,                                 /*tp_is_gc*/
   };

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to