[issue6284] C/API PyErr_AsUnicode()

STINNER Victor report at bugs.python.org
Fri Jan 7 23:45:12 CET 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

/* Returns the exception string as a new
   PyUnicode object or NULL if the conversion failed */

NULL is not very useful to analyze the error :-/ Why don't keep errors if the conversion failed? The caller will be responsible to use the new error, or to clear it.

If PyErr_AsUnicode() raises a new error on conversion error, you should raise an error on:

+	if (!PyErr_Occurred())
+		return NULL;

On keep PyImport_ImportModule(), PyObject_CallMethod() and PyObject_GetAttrString() error.

Oh, by the way, PyErr_AsUnicode returns NULL and raise an error if PyObject_CallObject() failed (if StringIO().getvalue() failed).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6284>
_______________________________________


More information about the Python-bugs-list mailing list