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


Groups > comp.lang.python > #75406

Re: Convert Python 3 ResourceWarnings into exception

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'warnings': 0.04; 'subject:Python': 0.06; 'assuming': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'record.': 0.09; 'subject:into': 0.09; 'python': 0.11; 'garbage': 0.16; 'message-id:@post.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:Convert': 0.16; 'subject:exception': 0.16; 'exception': 0.16; '(not': 0.18; 'mechanism': 0.19; 'header :User-Agent:1': 0.23; 'error': 0.23; 'daniel': 0.26; 'header:X -Complaints-To:1': 0.27; 'tried': 0.27; 'correct': 0.29; 'raise': 0.29; "doesn't": 0.30; 'exceptions': 0.31; 'prints': 0.31; 'writes:': 0.31; 'guess': 0.33; '"the': 0.34; 'created': 0.35; 'there': 0.35; 'module.': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'turn': 0.37; 'being': 0.38; 'to:addr:python- list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'users': 0.40; 'most': 0.60; 'new': 0.61; 'such': 0.63; 'taking': 0.65; 'answer.': 0.68; 'gathering': 0.68; 'skip:w 30': 0.69; 'collection.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Piotr Dobrogost <p@gmane-2014.dobrogost.net>
Subject Re: Convert Python 3 ResourceWarnings into exception
Date Thu, 31 Jul 2014 08:54:43 +0000 (UTC)
References <loom.20140730T151414-276@post.gmane.org> <lrbiam$l7l$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host sea.gmane.org
User-Agent Loom/3.14 (http://gmane.org/)
X-Loom-IP 195.117.20.144 (Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12460.1406796903.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406796903 news.xs4all.nl 2881 [2001:888:2000:d::a6]:37484
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75406

Show key headers only | 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