summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-07-13 13:59:39 (GMT)
committerThomas Heller <theller@ctypes.org>2007-07-13 13:59:39 (GMT)
commit1421b001625b1108d4c8899c821acf8bf444f714 (patch)
tree2cba72475f6b74ab586855db38cf9e18fc10dcde /Modules
parent928713c740c282063fc47c0c28f128f3ebd619e9 (diff)
downloadcpython-1421b001625b1108d4c8899c821acf8bf444f714.zip
cpython-1421b001625b1108d4c8899c821acf8bf444f714.tar.gz
cpython-1421b001625b1108d4c8899c821acf8bf444f714.tar.bz2
Repair COMError. Since exceptions are new style classes now, setting
the methods and docstring after the type creation does not work, they must be in the dictionary before creating the type.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 34b6829..8eeb865 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4520,11 +4520,6 @@ create_comerror(void)
PyObject *s;
int status;
- ComError = PyErr_NewException("_ctypes.COMError",
- NULL,
- dict);
- if (ComError == NULL)
- return -1;
while (methods->ml_name) {
/* get a wrapper for the built-in function */
PyObject *func = PyCFunction_New(methods, NULL);
@@ -4539,13 +4534,24 @@ create_comerror(void)
Py_DECREF(meth);
++methods;
}
- Py_INCREF(ComError);
+
s = PyString_FromString(comerror_doc);
if (s == NULL)
return -1;
status = PyDict_SetItemString(dict, "__doc__", s);
Py_DECREF(s);
- return status;
+ if (status == -1) {
+ Py_DECREF(dict);
+ return -1;
+ }
+
+ ComError = PyErr_NewException("_ctypes.COMError",
+ NULL,
+ dict);
+ if (ComError == NULL)
+ return -1;
+
+ return 0;
}
#endif