Convert Python 3 ResourceWarnings into exception
Terry Reedy
tjreedy at udel.edu
Wed Jul 30 15:50:42 EDT 2014
On 7/30/2014 9:24 AM, Piotr Dobrogost wrote:
> Hi!
>
> Recently A. Jesse Jiryu Davis asked at Stackoverflow
> (http://stackoverflow.com/q/24717027/95735) if there is "a way to force a
> Python 3 unittest to fail, rather than simply print a warning to stderr, if
> it causes any ResourceWarning?" Daniel Harding, in the accepted answer,
> states it's not possible.
>
> Is it really the case?
>
> For sake of context, here I believe is the place, where
> PyErr_WriteUnraisable is being called in this case –
> http://hg.python.org/cpython/annotate/c0e311e010fc/Modules/socketmodule.c#l3857
python -W error ...
"Raise an exception instead of printing a warning message."
You can also turn this on with the warnings module. Assuming that this
works for ResourceWarning, which is should, please correct the SO record.
--
Terry Jan Reedy
More information about the Python-list
mailing list