Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38852
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'warnings': 0.03; 'explicitly': 0.04; 'attribute': 0.05; 'context': 0.05; 'debug': 0.05; 'finally:': 0.05; 'ignored': 0.05; 'try:': 0.07; 'python': 0.09; 'modulo': 0.09; 'nameerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject: <': 0.09; 'def': 0.10; 'effect,': 0.16; 'fine.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:generator': 0.16; 'subject:object': 0.16; 'wrote:': 0.17; 'integer': 0.17; 'yield': 0.17; 'tests': 0.18; '>>>': 0.18; 'code,': 0.18; '"",': 0.22; 'form:': 0.22; 'skip:_ 20': 0.22; 'work,': 0.22; "i've": 0.23; 'seems': 0.23; 'pass': 0.25; 'tried': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'header:X -Complaints-To:1': 0.28; 'run': 0.28; 'catching': 0.29; 'division': 0.29; 'point': 0.31; 'file': 0.32; 'running': 0.32; 'print': 0.32; 'traceback': 0.33; 'zero': 0.33; 'to:addr:python- list': 0.33; 'hi,': 0.33; 'otherwise.': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'closing': 0.36; 'subject:" ': 0.36; 'success.': 0.36; 'item': 0.37; 'skip:z 10': 0.37; 'unit': 0.38; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'side': 0.61; 'subject:...': 0.63; 'numerous': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: "Exception ... in <generator object ...> ignored" Messages |
| Date | Thu, 14 Feb 2013 09:00:58 +0100 |
| Organization | None |
| References | <CABxKp+miRg-i+0oqMNOc6K9w_swKztBs9tjL=2bMe1mcJ3L0kg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084b8a8.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1760.1360828866.2939.python-list@python.org> (permalink) |
| Lines | 58 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1360828866 news.xs4all.nl 6893 [2001:888:2000:d::a6]:36373 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:38852 |
Show key headers only | View raw
Ami Tavory wrote: > Hi, > > Running the unit tests for some generator code, prints, as a side > effect, > numerous messages of the form: > > ... > Exception NameError: "global name 'l' is not defined" in <generator object > _dagpype_internal_fn_act at 0x9d4c500> ignored > Exception AttributeError: "'NoneType' object has no attribute 'close'" in > <generator object split at 0x7601640> ignored > Exception AttributeError: "'NoneType' object has no attribute 'close'" in > <generator object split at 0x7601690> ignored > ... > > The tests otherwise run fine. > > Is there any way to catch the point where such a message originates, and > print a traceback? I find it difficult to debug otherwise. I've tried > running Python with -W error, catching warnings with context managers, and > so forth, but without any success. >>> def g(): ... try: ... yield 42 ... finally: ... 1/0 ... >>> for item in g(): ... break ... Exception ZeroDivisionError: 'integer division or modulo by zero' in <generator object g at 0x7f990243b0f0> ignored Can you exhaust the generator? >>> for item in g(): ... pass ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 5, in g ZeroDivisionError: integer division or modulo by zero Explicitly closing the generator seems to work, too: >>> x = g() >>> next(x) 42 >>> x.close() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 5, in g ZeroDivisionError: integer division or modulo by zero
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: "Exception ... in <generator object ...> ignored" Messages Peter Otten <__peter__@web.de> - 2013-02-14 09:00 +0100
csiph-web