[pypy-svn] r73563 - in pypy/branch/cpython-extension/pypy/module/cpyext: . include src

xoraxax at codespeak.net xoraxax at codespeak.net
Thu Apr 8 18:35:00 CEST 2010


Author: xoraxax
Date: Thu Apr  8 18:34:58 2010
New Revision: 73563

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/include/bufferobject.h
   pypy/branch/cpython-extension/pypy/module/cpyext/src/bufferobject.c
Log:
Refactored code a bit but we still get the segfault.

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py	Thu Apr  8 18:34:58 2010
@@ -34,6 +34,7 @@
         #XXX: segfaults
         #for func in api.INIT_FUNCTIONS:
         #    func()
+        #    state.check_and_raise_exception()
 
 # import these modules to register api functions by side-effect
 import pypy.module.cpyext.pyobject

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Thu Apr  8 18:34:58 2010
@@ -28,7 +28,7 @@
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.rpython.lltypesystem.lloperation import llop
 
-DEBUG_WRAPPER = False
+DEBUG_WRAPPER = True
 
 # update these for other platforms
 Py_ssize_t = lltype.Signed
@@ -229,7 +229,7 @@
     'PyArg_ParseTuple', 'PyArg_UnpackTuple', 'PyArg_ParseTupleAndKeywords',
     'PyString_FromFormat', 'PyString_FromFormatV', 'PyModule_AddObject', 
     'Py_BuildValue', 'PyTuple_Pack', 'PyErr_Format',
-    'PyBuffer_FromMemory',
+    'PyBuffer_FromMemory', 'PyBufferType',
 ]
 TYPES = {}
 GLOBALS = { # this needs to include all prebuilt pto, otherwise segfaults occur
@@ -407,6 +407,10 @@
                                TP, compilation_info=eci)
         globals()['va_get_%s' % name_no_star] = func
 
+def setup_init_functions(eci):
+    INIT_FUNCTIONS.extend([
+        rffi.llexternal('init_bufferobject', [], lltype.Void, compilation_info=eci)
+    ])
 
 def bootstrap_types(space):
     from pypy.module.cpyext.pyobject import make_ref
@@ -500,10 +504,8 @@
             ctypes.c_void_p)
 
     setup_va_functions(eci)
-    
-    INIT_FUNCTIONS.extend([
-        rffi.llexternal('init_bufferobject', [], lltype.Void, compilation_info=eci)
-    ])
+   
+    setup_init_functions(eci)
     return modulename.new(ext='')
 
 def generate_macros(export_symbols, rename=True, do_deref=True):
@@ -640,6 +642,7 @@
     for name, func in FUNCTIONS_STATIC.iteritems():
         func.get_wrapper(space).c_name = name
 
+    setup_init_functions(eci)
 
 @unwrap_spec(ObjSpace, str, str)
 def load_extension_module(space, path, name):

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/bufferobject.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/bufferobject.h	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/bufferobject.h	Thu Apr  8 18:34:58 2010
@@ -9,7 +9,7 @@
 extern "C" {
 #endif
 
-static PyTypeObject PyBuffer_Type;
+PyTypeObject PyBuffer_Type;
 
 #define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type)
 

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/src/bufferobject.c
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/src/bufferobject.c	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/src/bufferobject.c	Thu Apr  8 18:34:58 2010
@@ -2,6 +2,9 @@
 /* Buffer object implementation */
 
 #include "Python.h"
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
 
 
 typedef struct {
@@ -822,7 +825,7 @@
 	(charbufferproc)buffer_getcharbuf,
 };
 
-static PyTypeObject PyBuffer_Type = {
+PyTypeObject PyBuffer_Type = {
     PyObject_HEAD_INIT(NULL)
     0,
 	"buffer",



More information about the Pypy-commit mailing list