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


Groups > comp.lang.python > #84893

Re: The Most Diabolical Python Antipattern

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 <ian.g.kelly@gmail.com>
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 <madpuv$he7$1@ger.gmane.org> <20150129113238.7eaa986d@bigbox.christie.dr> <mailman.18286.1422571931.18130.python-list@python.org> <87r3uchjyg.fsf@elektro.pacujo.net> <mailman.18296.1422605482.18130.python-list@python.org> <87r3ucljyv.fsf@elektro.pacujo.net> <87fvaslh9h.fsf@elektro.pacujo.net> <mailman.18306.1422631319.18130.python-list@python.org> <87zj90jngf.fsf@elektro.pacujo.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 30 Jan 2015 08:42:04 -0700
Subject Re: The Most Diabolical Python Antipattern
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18307.1422632572.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Fri, Jan 30, 2015 at 8:30 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Ian Kelly <ian.g.kelly@gmail.com>:
>
>> 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.

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


Thread

Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-29 15:51 -0700
  Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 08:16 +0200
    Re: The Most Diabolical Python Antipattern Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-30 08:10 +0000
      Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 11:02 +0200
        Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 02:17 -0700
        Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 12:00 +0200
          Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 08:21 -0700
            Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 17:30 +0200
              Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 08:42 -0700
                Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 17:56 +0200
                Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 09:38 -0700
              Re: The Most Diabolical Python Antipattern Chris Angelico <rosuav@gmail.com> - 2015-01-31 02:55 +1100
    Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 02:11 -0700
    Re: The Most Diabolical Python Antipattern Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-31 01:28 +0000

csiph-web