Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84872
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'finally:': 0.07; 'except:': 0.09; 'lawrence': 0.09; 'try:': 0.09; 'valueerror:': 0.09; 'variant': 0.09; 'python': 0.11; 'jan': 0.12; 'exception:': 0.16; 'letting': 0.16; 'throw': 0.16; 'unexpected': 0.16; 'url:peps': 0.16; 'valueerror': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'error': 0.23; 'url:dev': 0.24; 'changes,': 0.26; 'logging': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'bug?': 0.31; 'url:python': 0.33; 'running': 0.33; 'call.': 0.33; 'fri,': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'problem': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'url:org': 0.36; 'depends': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'subject:The': 0.64; 'more': 0.64; '30,': 0.65; '2015': 0.84; '2:02': 0.84; 'bare': 0.84; 'surface': 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=/oG9LfMVl0AK7/AGDnzoMgvzGPTp8jovbEFuYHnQsak=; b=GWXiCdMSFbagmKt4E7JXckkxiEYHkIXYs5kNDbyEgJM1pwxTUr3C0K2fUBaGGOBgZ+ 4xdJbOJoIqI+/8qSKmakAZG+AI04M5+1Ig8qozg78BtundthCQI00RxZuxT+qG3xINL4 tO5uDMc6AJECH1CXqGMTwP8v06QVWRkVUB+n3UB3by1mxWyp+oL9T/rmSN4wOxQaB/rf lPvyJW3wYyqWg+iTavFd9mpWyw9daE1W6kMJ7kzlRx6b5NbVI4vuNnjGo6BSR2y3Yrp8 rHnembL/TJqtHPFqLLkK0yKld3z+FXbr6BkGtYhAEa+eOoAWlwfPtC7cZNKLAYuYykIf +lDA== |
| X-Received | by 10.66.154.196 with SMTP id vq4mr7420115pab.146.1422609471747; Fri, 30 Jan 2015 01:17:51 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <87r3ucljyv.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> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 30 Jan 2015 02:17:11 -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.18300.1422609481.18130.python-list@python.org> (permalink) |
| Lines | 46 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1422609481 news.xs4all.nl 2889 [2001:888:2000:d::a6]:52143 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:84872 |
Show key headers only | View raw
On Fri, Jan 30, 2015 at 2:02 AM, Marko Rauhamaa <marko@pacujo.net> wrote: > Mark Lawrence <breamoreboy@yahoo.co.uk>: > >> On 30/01/2015 06:16, Marko Rauhamaa wrote: >>> How about: >>> >>> ============================== >>> try: >>> do_interesting_stuff() >>> except ValueError: >>> try: >>> log_it() >>> except: >>> pass >>> raise >>> ============================== >>> >>> Surprisingly this variant could raise an unexpected exception: >>> >>> ============================== >>> try: >>> do_interesting_stuff() >>> except ValueError: >>> try: >>> log_it() >>> finally: >>> raise >>> ============================== >>> >>> A Python bug? >> >> It depends on the Python version that you're running - I think!!! See >> https://www.python.org/dev/peps/pep-3134/ > > TL;DR > > My Python did do exception chaining, but the problem is the surface > exception changes, which could throw off the whole error recovery. > > So I'm thinking I might have found a valid use case for the "diabolical > antipattern." I suppose, although it seems awfully contrived to me. In any case it would still be better with "except Exception" rather than the bare except. Unless re-raising that ValueError is more important to you than letting the user hit Ctrl-C during the logging call.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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