Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explicit': 0.07; 'exits': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'underscore': 0.09; '~ethan~': 0.09; 'times,': 0.14; 'adjusting': 0.16; 'bit.': 0.16; 'code?': 0.16; 'gotcha.': 0.16; 'ought': 0.16; 'raised.': 0.16; 'return,': 0.16; 'semantics': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'error': 0.23; "haven't": 0.24; "i've": 0.25; 'first,': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'code': 0.31; 'but': 0.35; 'adjust': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'kind': 0.63; 'real': 0.63; 'finally': 0.65; 'frank': 0.68; 'batchelder': 0.84; 'subject:try': 0.84; '1:47': 0.91 Date: Sat, 07 Jun 2014 15:49:23 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: try/except/finally References: <0a89c96d-de62-42ad-be48-6107ce10d215@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Exim-ID: 1WtPQR-0006M0-Ph X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:43243 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402184183 news.xs4all.nl 2849 [2001:888:2000:d::a6]:33442 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72936 On 06/06/2014 11:22 AM, Ned Batchelder wrote: > On 6/6/14 1:47 PM, Frank B wrote: >> >> Ok; thanks for the underscore and clarification. Just need to adjust my thinking a bit. > > Did this come up in real code? I've seen this point about finally/return semantics a number of times, but haven't seen > real code that needed adjusting based on it. I don't remember if I almost had this in real code or if I learned about it first, but it can definitely be a gotcha. It seems to me that if the try block exits with an explicit return, and then the finally block exits with an explicit return, some kind of error ought to be raised. -- ~Ethan~