[pypy-svn] r73435 - pypy/branch/cpython-extension/pypy/module/cpyext
xoraxax at codespeak.net
xoraxax at codespeak.net
Tue Apr 6 03:13:34 CEST 2010
Author: xoraxax
Date: Tue Apr 6 03:13:33 2010
New Revision: 73435
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/object.py
Log:
Rework allocation in object.py.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/object.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/object.py Tue Apr 6 03:13:33 2010
@@ -13,19 +13,16 @@
@cpython_api([PyTypeObjectPtr], PyObject)
def _PyObject_New(space, type):
- try:
- w_type = from_ref(space, rffi.cast(PyObject, type))
- except:
- import pdb; pdb.set_trace()
+ return _PyObject_NewVar(space, type, 0)
+
+ at cpython_api([PyTypeObjectPtr, Py_ssize_t], PyObject)
+def _PyObject_NewVar(space, type, size):
+ w_type = from_ref(space, rffi.cast(PyObject, type))
if isinstance(w_type, W_PyCTypeObject):
w_obj = space.allocate_instance(W_ObjectObject, w_type)
- return w_obj
+ return make_ref(space, w_obj, items=size)
assert False, "Please add more cases in _PyObject_New"
- at cpython_api([PyTypeObjectPtr, Py_ssize_t], PyObject)
-def _PyObject_NewVar(space, type, size): # XXX use size!
- return _PyObject_New(space, type)
-
@cpython_api([rffi.VOIDP_real], lltype.Void)
def PyObject_Del(space, obj):
lltype.free(obj, flavor='raw')
More information about the Pypy-commit
mailing list