summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c41
-rw-r--r--Modules/_ctypes/libffi/src/x86/ffi_darwin.c2
2 files changed, 41 insertions, 2 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index a4400cf..5319a9a 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4814,11 +4814,48 @@ static PyTypeObject PyComError_Type = {
static int
create_comerror(void)
{
- PyComError_Type.tp_base = (PyTypeObject*)PyExc_Exception;
- if (PyType_Ready(&PyComError_Type) < 0)
+ PyObject *dict = PyDict_New();
+ PyMethodDef *methods = comerror_methods;
+ PyObject *s;
+ int status;
+
+ if (dict == NULL)
return -1;
+
+ while (methods->ml_name) {
+ /* get a wrapper for the built-in function */
+ PyObject *func = PyCFunction_New(methods, NULL);
+ PyObject *meth;
+ if (func == NULL)
+ goto error;
+ meth = PyMethod_New(func, NULL, ComError);
+ Py_DECREF(func);
+ if (meth == NULL)
+ goto error;
+ PyDict_SetItemString(dict, methods->ml_name, meth);
+ Py_DECREF(meth);
+ ++methods;
+ }
+
+ s = PyString_FromString(comerror_doc);
+ if (s == NULL)
+ goto error;
ComError = (PyObject*)&PyComError_Type;
+ status = PyDict_SetItemString(dict, "__doc__", s);
+ Py_DECREF(s);
+ if (status == -1)
+ goto error;
+
+ ComError = PyErr_NewException("_ctypes.COMError",
+ NULL,
+ dict);
+ if (ComError == NULL)
+ goto error;
+
return 0;
+ error:
+ Py_DECREF(dict);
+ return -1;
}
#endif
diff --git a/Modules/_ctypes/libffi/src/x86/ffi_darwin.c b/Modules/_ctypes/libffi/src/x86/ffi_darwin.c
index 71ac587..6726afa 100644
--- a/Modules/_ctypes/libffi/src/x86/ffi_darwin.c
+++ b/Modules/_ctypes/libffi/src/x86/ffi_darwin.c
@@ -146,7 +146,9 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
+#endif
cif->flags = (unsigned) cif->rtype->type;
break;