Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'ignored': 0.05; 'except:': 0.07; 'try:': 0.07; 'doing?': 0.09; 'path)': 0.09; 'worked.': 0.09; 'def': 0.10; 'encoding': 0.15; '*should*': 0.16; 'correctly,': 0.16; 'exceptions.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'read:': 0.16; 'subject:generator': 0.16; 'swallows': 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; 'idea': 0.24; 'tried': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'run': 0.28; 'received:192.168.1.3': 0.29; 'case,': 0.29; 'code': 0.31; 'problem.': 0.32; 'print': 0.32; 'problem': 0.33; 'to:addr:python- list': 0.33; 'whatever': 0.35; 'path': 0.35; 'open': 0.35; 'except': 0.36; 'but': 0.36; 'bad': 0.37; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'virtually': 0.65; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'fil': 0.84; 'maybe,': 0.84; 'reply-to:addr:python.org': 0.84; 'reporting,': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=OqzNOlDt c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=b2nRVtXOy8EA:10 a=ljIDKrVDQJQA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=-7UPSeOjsbwA:10 a=sH1lVz5Xz42IV1lX8JoA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Sat, 20 Oct 2012 23:22:52 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: 'generator ignored GeneratorExit'' References: <50830394.6020100@earthlink.net> In-Reply-To: <50830394.6020100@earthlink.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350771772 news.xs4all.nl 6922 [2001:888:2000:d::a6]:52457 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31824 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 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.