Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75406

Re: Convert Python 3 ResourceWarnings into exception

From Piotr Dobrogost <p@gmane-2014.dobrogost.net>
Subject Re: Convert Python 3 ResourceWarnings into exception
Date 2014-07-31 08:54 +0000
References <loom.20140730T151414-276@post.gmane.org> <lrbiam$l7l$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.12460.1406796903.18130.python-list@python.org> (permalink)

Show all headers | View raw


Terry Reedy <tjreedy <at> udel.edu> writes:
> 
> 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.


Thanks for taking time to answer.
Please notice that OP already tried
warnings.simplefilter(action='error', category=ResourceWarning)
with no luck.

Also, in the answer, Daniel states the following:
"The ResourceWarning is indeed being generated during garbage collection,
and Python prints a message because it doesn't have a way to raise an
exception at that point."

If it were true that would have been rather unfortunate as I guess most
ResourceWarnings are being generated during garbage collection. In that case
to let users get hold on such warnings there would need to be created new
mechanism for gathering warnings (not based on exceptions as a mean of
transport).

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Convert Python 3 ResourceWarnings into exception Piotr Dobrogost <p@gmane-2014.dobrogost.net> - 2014-07-31 08:54 +0000

csiph-web