Kaydet (Commit) 55b8c3e2 authored tarafından Thomas Heller's avatar Thomas Heller

Fixed refcounts and error handling.

Should not be merged to py3k branch.
üst 5af2f745
...@@ -4956,16 +4956,19 @@ create_comerror(void) ...@@ -4956,16 +4956,19 @@ create_comerror(void)
PyObject *s; PyObject *s;
int status; int status;
if (dict == 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);
PyObject *meth; PyObject *meth;
if (func == NULL) if (func == NULL)
return -1; goto error;
meth = PyMethod_New(func, NULL, ComError); meth = PyMethod_New(func, NULL, ComError);
Py_DECREF(func); Py_DECREF(func);
if (meth == NULL) if (meth == NULL)
return -1; goto error;
PyDict_SetItemString(dict, methods->ml_name, meth); PyDict_SetItemString(dict, methods->ml_name, meth);
Py_DECREF(meth); Py_DECREF(meth);
++methods; ++methods;
...@@ -4973,21 +4976,22 @@ create_comerror(void) ...@@ -4973,21 +4976,22 @@ create_comerror(void)
s = PyString_FromString(comerror_doc); s = PyString_FromString(comerror_doc);
if (s == NULL) if (s == NULL)
return -1; goto error;
status = PyDict_SetItemString(dict, "__doc__", s); status = PyDict_SetItemString(dict, "__doc__", s);
Py_DECREF(s); Py_DECREF(s);
if (status == -1) { if (status == -1)
Py_DECREF(dict); goto error;
return -1;
}
ComError = PyErr_NewException("_ctypes.COMError", ComError = PyErr_NewException("_ctypes.COMError",
NULL, NULL,
dict); dict);
if (ComError == NULL) if (ComError == NULL)
return -1; goto error;
return 0; return 0;
error:
Py_DECREF(dict);
return -1;
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment