Clear error indicator before calling pygi_pyerr_format

Merged Simon McVittie requested to merge smcv/pygobject:clear-error-before-calling-str into master

These pygi_pyerr_format calls end up stringifying the 'number' object with PyObject_Str(), but since it is considered invalid to call PyObject_Str() with the exception indicator set, and Python builds where Py_DEBUG is defined will fail an assertion if it is. We are about to set a different exception anyway, so clearing the exception indicator here is harmless.

This fixes build-time test failures when PyGObject is built against Debian's python3.?-dbg interpreters, which are built with Py_DEBUG defined.

Signed-off-by: Simon McVittie

Merge request reports