Problem with error handling
От | Eric Snow |
---|---|
Тема | Problem with error handling |
Дата | |
Msg-id | D2F744D05ED19D45A4A7757F49274A8B042F126E@IAD-WPRD-XCHB01.corp.verio.net обсуждение исходный текст |
Ответы |
Re: Problem with error handling
|
Список | psycopg |
I'm getting a "SystemError: null argument to internal routine" problem that is gobbling up the actual error. I turned on debugging and see that the problem is that my connection is closed (and I have to connect a second time to get it to work). However, the SystemError hid this until I turned on debugging. In trying to find why the SystemError is happening, I found that at the point pq_raise is called, no exception has been set. The conn and pgres objects are fine and the cursor is NULL. The following call is NULL: code = PQresultErrorField(pgres, PG_DIAG_SQLSTATE); This results in "exc" staying null. Thus, when psyco_set_error is called, only msg and pgerror are not NULL. Since the cursor is NULL, the connection object is not pulled, and the following line is valid: pymsg = conn_text_from_chars(conn, msg) Subsequently, the following is called with "exc" set to NULL: err = PyObject_CallFunctionObjArgs(exc, pymsg, NULL); Thus err is NULL and the if statement is not called. Because it is not called, PyErr_SetObject is never called. All of this started with a call to cursor.execute in Python. That dropped down into the C module's psyco_curs_execute. That returns NULL without the PyErr object set, which results in the SystemError. I am guessing that the solution is one of the following: * PQresultErrorField should not have returned NULL * "exc" should have been calculated another way (like an else after the "if (code != NULL)") Regardless of the solution, thanks for your time. -eric This email message is intended for the use of the person to whom it has been sent, and may contain information that is confidentialor legally protected. If you are not the intended recipient or have received this message in error, you are notauthorized to copy, distribute, or otherwise use this message or its attachments. Please notify the sender immediatelyby return e-mail and permanently delete this message and any attachments. Verio, Inc. makes no warranty that thisemail is error or virus free. Thank you.
В списке psycopg по дате отправления: