mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 11:36:37 +03:00
Fixed potential failures while setting exceptions attributes
This commit is contained in:
parent
7d67ecbed3
commit
09be4dc5d1
|
@ -635,15 +635,17 @@ psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg,
|
|||
}
|
||||
|
||||
if (pgerror) {
|
||||
t = conn_text_from_chars(conn, pgerror);
|
||||
PyObject_SetAttrString(err, "pgerror", t);
|
||||
Py_DECREF(t);
|
||||
if ((t = conn_text_from_chars(conn, pgerror))) {
|
||||
PyObject_SetAttrString(err, "pgerror", t);
|
||||
Py_DECREF(t);
|
||||
}
|
||||
}
|
||||
|
||||
if (pgcode) {
|
||||
t = conn_text_from_chars(conn, pgcode);
|
||||
PyObject_SetAttrString(err, "pgcode", t);
|
||||
Py_DECREF(t);
|
||||
if ((t = conn_text_from_chars(conn, pgcode))) {
|
||||
PyObject_SetAttrString(err, "pgcode", t);
|
||||
Py_DECREF(t);
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_SetObject(exc, err);
|
||||
|
|
Loading…
Reference in New Issue
Block a user