mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
928713c740
commit
1421b00162
|
@ -4520,11 +4520,6 @@ create_comerror(void)
|
||||||
PyObject *s;
|
PyObject *s;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
ComError = PyErr_NewException("_ctypes.COMError",
|
|
||||||
NULL,
|
|
||||||
dict);
|
|
||||||
if (ComError == NULL)
|
|
||||||
return -1;
|
|
||||||
while (methods->ml_name) {
|
while (methods->ml_name) {
|
||||||
/* get a wrapper for the built-in function */
|
/* get a wrapper for the built-in function */
|
||||||
PyObject *func = PyCFunction_New(methods, NULL);
|
PyObject *func = PyCFunction_New(methods, NULL);
|
||||||
|
@ -4539,13 +4534,24 @@ create_comerror(void)
|
||||||
Py_DECREF(meth);
|
Py_DECREF(meth);
|
||||||
++methods;
|
++methods;
|
||||||
}
|
}
|
||||||
Py_INCREF(ComError);
|
|
||||||
s = PyString_FromString(comerror_doc);
|
s = PyString_FromString(comerror_doc);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
status = PyDict_SetItemString(dict, "__doc__", s);
|
status = PyDict_SetItemString(dict, "__doc__", s);
|
||||||
Py_DECREF(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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue