How to suppress exception printing to console?

Steven W. Orr steveo at
Fri Jun 1 05:04:41 CEST 2012

On 5/31/2012 3:57 AM, Qi wrote:

> I have an application that embedding Python into C++.
> When any exception occurred in C++ code, PyErr_SetString will
> be called to propagate the exception to Python.
> The problem is, some unit tests trigger exception on intention.
> So it's OK to have the exceptions. But Python will still print
> the exception to console, polluting the unit test output.
> My question is, is there any way to disable exception reporting
> to console from either C++ or Python code?

How about a big hammer?

except Exception:

Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at

More information about the Python-list mailing list