Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.063 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'subject:Python': 0.06; 'exception.': 0.09; 'raises': 0.09; 'jan': 0.12; 'chained': 0.16; 'clauses.': 0.16; 'handled.': 0.16; 'exception': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'affects': 0.24; 'order.': 0.26; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; '8:30': 0.31; 'exceptions': 0.31; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'being': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'catch': 0.60; 'ian': 0.60; 'most': 0.60; 'subject:The': 0.64; '30,': 0.65; 'finally': 0.65; 'lose': 0.68; '2015': 0.84; 'bare': 0.84; 'scary.': 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=KhRFGWuzEHadHWm2JTeSuNp07noVMr8EcsrbYsi+jdw=; b=ItxKGeEG4vCvqzKHEcdIZnuV5iuINgBsxqQSmmI0WWovbwlLOYy7u8Ab8sc55WzNwA bnLdGQcyVepGpXdKME6xc2JQceWp+yD1/waWXwtea6H3lWFPV/SVMQfKBXXGTOHiba16 qfWRlOpvViIDTVqgceW33/tTajGclqyjS2M7WwpbDCZH5xeJ8EJtRilafUdVcZNFacBK eA7XMS5Y25QLZuPjDf32RCzkVKIVqp8VZv/7SdL6DwAgHSnXecjudDXfGfgD6zpi5ny3 NoAYTCn5JsSPJN5NIeaqNKM+cnoKT2b1QPYZd/nrDh3cdsxynmZKQ9HI7n8Qp0cd+a2u wbZg== X-Received: by 10.66.97.6 with SMTP id dw6mr9575517pab.114.1422632564669; Fri, 30 Jan 2015 07:42:44 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <87zj90jngf.fsf@elektro.pacujo.net> References: <20150129113238.7eaa986d@bigbox.christie.dr> <87r3uchjyg.fsf@elektro.pacujo.net> <87r3ucljyv.fsf@elektro.pacujo.net> <87fvaslh9h.fsf@elektro.pacujo.net> <87zj90jngf.fsf@elektro.pacujo.net> From: Ian Kelly Date: Fri, 30 Jan 2015 08:42:04 -0700 Subject: Re: The Most Diabolical Python Antipattern To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422632572 news.xs4all.nl 2869 [2001:888:2000:d::a6]:35087 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84893 On Fri, Jan 30, 2015 at 8:30 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> The bare raise re-raises the most recent exception that is being >> handled. The "raise e" raises that exception specifically, which is >> not the most recent in the case of a secondary exception. > > Scary. That affects all finally clauses. Must remember that. > > The pitfall is avoided by using the "except: pass" antipattern but then > you lose exception chaining. Like I suggested earlier, just don't catch the inner exception at all. The result will be both exceptions propagated, chained in the proper order.