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


Groups > comp.lang.python > #31824

Re: 'generator ignored GeneratorExit''

Date 2012-10-20 23:22 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: 'generator ignored GeneratorExit''
References <50830394.6020100@earthlink.net>
Newsgroups comp.lang.python
Message-ID <mailman.2569.1350771772.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 2012-10-20 21:03, Charles Hixson 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?
>
That code has a bare except, which is virtually always a bad idea
because it swallows _all_ exceptions. Maybe, in this case, it's
swallowing an exception that would tell you the cause of the problem.

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


Thread

Re: 'generator ignored GeneratorExit'' MRAB <python@mrabarnett.plus.com> - 2012-10-20 23:22 +0100

csiph-web