Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31826
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| 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; 'explicitly': 0.04; 'ignored': 0.05; 'except:': 0.07; 'try:': 0.07; 'doing?': 0.09; 'oserror': 0.09; 'path)': 0.09; 'propagate': 0.09; 'worked.': 0.09; 'def': 0.10; 'encoding': 0.15; 'sat,': 0.15; '*should*': 0.16; 'correctly,': 0.16; 'oct': 0.16; 'read:': 0.16; 'subject:generator': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'module,': 0.17; 'yield': 0.17; 'appears': 0.18; 'changes': 0.20; 'import': 0.21; "i've": 0.23; 'raise': 0.24; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'instead.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; 'catching': 0.29; 'probably': 0.29; 'normally': 0.30; 'received:209.85.215.46': 0.30; 'up.': 0.31; 'code': 0.31; 'print': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'whatever': 0.35; 'path': 0.35; 'open': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'except': 0.36; 'but': 0.36; 'received:209': 0.37; 'object': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'more': 0.63; '20,': 0.65; 'fil': 0.84; 'reporting,': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=pmlAl/KtzvgM+32yHayk+KgPa+2LsoIsmQGLhOkcsw4=; b=RXZVaQk4LkTFqEuUQheO7+IKzT/WNBzjIG6UtEd9PgyKGEiGAOUtCW1EjznsuRiaMM gPmL3HwS9/bR3Qj2MDEouiKu+hzFlJgfqbRA8skzz7uIfeEwXXJH9cKajUrCRzda3H6t 0PjoBBUALnYiXp0T7LKX7kkVw9HyMq858umQGomydENkPPfjuv5b4/s3Y9KYjmbE32zK TLzBrVq4JgLcA32wVG4GSn9dIHK1g8XraGWvPh2ZSoIXjqXlR3Xozd3AhMiIm+jWc3IE HN/7uA3s4iGqGAWUsNgrANVUF32bX16Wjikev3kWsAEM9bP23jEA0H7YCJGDH8JMVewA GeMw== |
| MIME-Version | 1.0 |
| In-Reply-To | <50830394.6020100@earthlink.net> |
| References | <50830394.6020100@earthlink.net> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sat, 20 Oct 2012 17:28:32 -0600 |
| Subject | Re: 'generator ignored GeneratorExit'' |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.2571.1350775743.27098.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350775743 news.xs4all.nl 6986 [2001:888:2000:d::a6]:38966 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31826 |
Show key headers only | View raw
On Sat, Oct 20, 2012 at 2:03 PM, Charles Hixson
<charleshixsn@earthlink.net> wrote:
> If I run the following code in the same module, it works correctly, but if I
> import it I get the message:
> Exception RuntimeError: 'generator ignored GeneratorExit' in <generator
> object getNxtFile at 0x7f932f884f50> ignored
>
> def getNxtFile (startDir, exts = ["txt", "utf8"]):
> try:
> for path in getNxtPath (startDir, exts):
> try:
> fil = open (path, encoding = "utf-8-sig")
> yield fil
> except:
> print ("Could not read: ", path)
> except GeneratorExit:
> raise StopIteration
>
> The message appears to be purely informational, but I *would* like to fix
> whatever problem it's reporting, and none of the changes that I've tried
> have worked. What *should* I be doing?
The bare except is probably catching the GeneratorExit exception and
swallowing it. Try catching a more specific exception like OSError or
even just Exception instead.
Also, you don't need to explicitly catch GeneratorExit just to raise
StopIteration. The generator will normally stop on GeneratorExit,
provided the exception is actually able to propagate up.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: 'generator ignored GeneratorExit'' Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-20 17:28 -0600
csiph-web