UnicodeError instead of UnicodeWarning
Chris Rebert
clp2 at rebertia.com
Tue Oct 25 04:11:39 EDT 2011
2011/10/25 Michael Ströder <michael at stroeder.com>:
> HI!
>
> For tracking the cause of a UnicodeWarning I'd like to make the Python
> interpreter to raise an UnicodeError exception with full stack trace. Is there
> a short trick to achieve this?
from exceptions import UnicodeWarning
from warnings import filterwarnings
filterwarnings(action="error", category=UnicodeWarning)
This will cause UnicodeWarnings to be raised as exceptions when they occur.
Cheers,
Chris
--
http://rebertia.com
More information about the Python-list
mailing list