c6247fd
diff -up Python-2.7rc1/Modules/_ctypes/callbacks.c.selinux Python-2.7rc1/Modules/_ctypes/callbacks.c
c6247fd
--- Python-2.7rc1/Modules/_ctypes/callbacks.c.selinux	2010-05-09 10:46:46.000000000 -0400
c6247fd
+++ Python-2.7rc1/Modules/_ctypes/callbacks.c	2010-06-08 08:44:18.357366200 -0400
c6247fd
@@ -21,8 +21,8 @@ CThunkObject_dealloc(PyObject *_self)
c6247fd
     Py_XDECREF(self->converters);
c6247fd
     Py_XDECREF(self->callable);
c6247fd
     Py_XDECREF(self->restype);
c6247fd
-    if (self->pcl)
c6247fd
-        _ctypes_free_closure(self->pcl);
c6247fd
+    if (self->pcl_write)
c6247fd
+        ffi_closure_free(self->pcl_write);
c6247fd
     PyObject_GC_Del(self);
c6247fd
 }
c6247fd
 
c6247fd
@@ -391,7 +391,8 @@ static CThunkObject* CThunkObject_new(Py
c6247fd
         return NULL;
c6247fd
     }
c6247fd
 
c6247fd
-    p->pcl = NULL;
c6247fd
+    p->pcl_exec = NULL;
c6247fd
+    p->pcl_write = NULL;
c6247fd
     memset(&p->cif, 0, sizeof(p->cif));
c6247fd
     p->converters = NULL;
c6247fd
     p->callable = NULL;
c6247fd
@@ -421,8 +422,9 @@ CThunkObject *_ctypes_alloc_callback(PyO
c6247fd
 
c6247fd
     assert(CThunk_CheckExact(p));
c6247fd
 
c6247fd
-    p->pcl = _ctypes_alloc_closure();
c6247fd
-    if (p->pcl == NULL) {
c6247fd
+    p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
c6247fd
+                                     &p->pcl_exec);
c6247fd
+    if (p->pcl_write == NULL) {
c6247fd
         PyErr_NoMemory();
c6247fd
         goto error;
c6247fd
     }
c6247fd
@@ -467,7 +469,9 @@ CThunkObject *_ctypes_alloc_callback(PyO
c6247fd
                      "ffi_prep_cif failed with %d", result);
c6247fd
         goto error;
c6247fd
     }
c6247fd
-    result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p);
c6247fd
+    result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
c6247fd
+                                  p,
c6247fd
+                                  p->pcl_exec);
c6247fd
     if (result != FFI_OK) {
c6247fd
         PyErr_Format(PyExc_RuntimeError,
c6247fd
                      "ffi_prep_closure failed with %d", result);
c6247fd
diff -up Python-2.7rc1/Modules/_ctypes/_ctypes.c.selinux Python-2.7rc1/Modules/_ctypes/_ctypes.c
c6247fd
--- Python-2.7rc1/Modules/_ctypes/_ctypes.c.selinux	2010-05-09 10:46:46.000000000 -0400
c6247fd
+++ Python-2.7rc1/Modules/_ctypes/_ctypes.c	2010-06-07 23:19:39.950146038 -0400
c6247fd
@@ -3463,7 +3463,7 @@ PyCFuncPtr_new(PyTypeObject *type, PyObj
c6247fd
     self->callable = callable;
c6247fd
 
c6247fd
     self->thunk = thunk;
c6247fd
-    *(void **)self->b_ptr = (void *)thunk->pcl;
c6247fd
+    *(void **)self->b_ptr = (void *)thunk->pcl_exec;
c6247fd
 
c6247fd
     Py_INCREF((PyObject *)thunk); /* for KeepRef */
c6247fd
     if (-1 == KeepRef((CDataObject *)self, 0, (PyObject *)thunk)) {
c6247fd
diff -up Python-2.7rc1/Modules/_ctypes/ctypes.h.selinux Python-2.7rc1/Modules/_ctypes/ctypes.h
c6247fd
--- Python-2.7rc1/Modules/_ctypes/ctypes.h.selinux	2010-05-09 10:46:46.000000000 -0400
c6247fd
+++ Python-2.7rc1/Modules/_ctypes/ctypes.h	2010-06-07 23:19:39.950146038 -0400
c6247fd
@@ -95,7 +95,8 @@ struct tagCDataObject {
c6247fd
 
c6247fd
 typedef struct {
c6247fd
     PyObject_VAR_HEAD
c6247fd
-    ffi_closure *pcl; /* the C callable */
c6247fd
+    ffi_closure *pcl_write; /* the C callable, writeable */
c6247fd
+    void *pcl_exec;         /* the C callable, executable */
c6247fd
     ffi_cif cif;
c6247fd
     int flags;
c6247fd
     PyObject *converters;
c6247fd
diff -up Python-2.7rc1/setup.py.selinux Python-2.7rc1/setup.py
c6247fd
--- Python-2.7rc1/setup.py.selinux	2010-06-07 23:19:39.922147795 -0400
c6247fd
+++ Python-2.7rc1/setup.py	2010-06-07 23:19:39.951145942 -0400
c6247fd
@@ -1864,8 +1864,7 @@ class PyBuildExt(build_ext):
c6247fd
                    '_ctypes/callbacks.c',
c6247fd
                    '_ctypes/callproc.c',
c6247fd
                    '_ctypes/stgdict.c',
c6247fd
-                   '_ctypes/cfield.c',
c6247fd
-                   '_ctypes/malloc_closure.c']
c6247fd
+                   '_ctypes/cfield.c']
c6247fd
         depends = ['_ctypes/ctypes.h']
c6247fd
 
c6247fd
         if sys.platform == 'darwin':