Make warning an exception?

Rob Gaddi rgaddi at highlandtechnology.invalid
Fri Dec 6 16:11:27 EST 2019


On 12/6/19 12:58 PM, Israel Brewster wrote:
> I was running some code and I saw this pop up in the console:
> 
> 2019-12-06 11:53:54.087 Python[85524:39651849] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
> 
> The only problem is, I have no idea what is generating that warning - I never call nextEventMatchingMask directly, so it must be getting called from one of the libraries I’m calling. Is there some way I can force python to throw an exception now, so my debugger can catch it and let me know where in my code the originating call is? I’ve tried stepping through the obvious options, with no luck so far.
> 
> ---
> Israel Brewster
> Software Engineer
> Alaska Volcano Observatory
> Geophysical Institute - UAF
> 2156 Koyukuk Drive
> Fairbanks AK 99775-7320
> Work: 907-474-5172
> cell:  907-328-9145
> 

You need to set the warning filter to "error", which you can do either with 
warnings.simplefilter at the start of your program or by setting the 
PYTHONWARNINGS environment variable.

https://docs.python.org/3/library/warnings.html#the-warnings-filter

This the same project you're having PySide/threading problems on?


More information about the Python-list mailing list