[ctypes-commit] ctypes/source _ctypes.c,1.335,1.336
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-06-09 07:09:13
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10277 Modified Files: _ctypes.c Log Message: Remove the index checking in Pointer_ass_item. This has the effect that you can modify any memory location by assigning the pointer items. A casted object will now contain the source objects '_objects' dictionary. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.335 retrieving revision 1.336 diff -C2 -d -r1.335 -r1.336 *** _ctypes.c 8 Jun 2006 14:45:19 -0000 1.335 --- _ctypes.c 9 Jun 2006 07:09:10 -0000 1.336 *************** *** 4119,4127 **** stgdict = PyObject_stgdict((PyObject *)self); - if (index != 0) { - PyErr_SetString(PyExc_IndexError, - "invalid index"); - return -1; - } size = stgdict->size / stgdict->length; --- 4119,4122 ---- *************** *** 4502,4510 **** if (result == NULL) return NULL; ! /* KeepRef consumes a refcount on src */ ! Py_INCREF(src); ! if (-1 == KeepRef(result, 0, src)) { ! Py_DECREF(result); ! return NULL; } /* Should we assert that result is a pointer type? */ --- 4497,4511 ---- if (result == NULL) return NULL; ! ! if (CDataObject_Check(src)) { ! CDataObject *obj = (CDataObject *)src; ! /* CData_GetContainer will initialize src.b_objects, we need ! this so it can be shared */ ! CData_GetContainer(obj); ! Py_XINCREF(obj->b_objects); ! result->b_objects = obj->b_objects; ! ! Py_XINCREF(obj->b_base); ! result->b_base = obj->b_base; } /* Should we assert that result is a pointer type? */ |