Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!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; 'cc:addr:python-list': 0.09; 'caveat': 0.09; 'it;': 0.09; 'knows?': 0.09; 'raised.': 0.09; 'spec': 0.09; 'exception': 0.13; 'api,': 0.16; 'bytecode': 0.16; 'cc:name:python': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'python/c': 0.16; 'set,': 0.16; 'subject:exception': 0.16; 'then?': 0.16; 'wrote:': 0.16; 'language': 0.19; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'sat,': 0.23; 'header:In- Reply-To:1': 0.24; 'chris': 0.26; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'blocking': 0.29; 'there.': 0.30; "i'm": 0.30; 'that.': 0.30; "can't": 0.32; 'maybe': 0.33; 'point': 0.33; 'raised': 0.33; 'covered': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'platforms,': 0.35; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'anything': 0.38; 'someone': 0.38; 'why': 0.39; 'sure': 0.39; 'does': 0.39; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'back': 0.62; 'interrupted': 0.76; 'chrisa': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=LHft7s+ORF618JVjhiqH+b7TDgzV5K7HakpusCYYaWw=; b=YvvCX9m7vYmD54m5WJtQdUm15WPegCDv+qYwFGnGi3he+NJuHIVBngwXOk6llMtcwX 0ObIuieKT+gUjPJX0ImucBhihCQZYVBGz+jELf3AmUzp70GgVt6FM0fQSNSAm8HK5lGo 3bFaLuSMQlH/iqcdWne+/ldBlyF5T1Ir3lMU/tBxuEKbVHfBu+RAwMiO3GpRHznzIPsh Ml4l2X5icsskAPHGL89u194dNdQ9JcypQ8DpwR84lFvwwn+OUoM7BnE5MfiuE+XvIDI6 j1OuoY0mPx6mNLEVc7oEdWN2DNhwUQeXsqxBCOG6MZqDTY8Ht2AYM2lWpkVHoiyT2jmD uILw== MIME-Version: 1.0 X-Received: by 10.50.143.37 with SMTP id sb5mr2004179igb.13.1439017705972; Sat, 08 Aug 2015 00:08:25 -0700 (PDT) In-Reply-To: References: <48587161-1bd6-47e4-b2c9-7a37c60a59e5@googlegroups.com> Date: Sat, 8 Aug 2015 17:08:25 +1000 Subject: Re: except block isn't catching exception From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439017714 news.xs4all.nl 2881 [2001:888:2000:d::a6]:39726 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95163 On Sat, Aug 8, 2015 at 4:56 PM, Ian Kelly wrote: > On Fri, Aug 7, 2015 at 8:44 PM, Chris Angelico wrote: >> The exception isn't happening inside sock.accept(), as I explained. So >> you can't catch it there. > > Where does the exception happen then? Your explanation only covered > why the blocking call cannot be interrupted by it, not why the > exception isn't simply raised when the blocking call finishes. > I'm not sure there's anything in the language spec about it; at least, I can't find it. But the last time I was digging in the Python/C API, there was a caveat that KeyboardInterrupt was raised *at some point after* Ctrl-C was hit - a flag gets set, and after every N bytecode instructions, the flag is checked, and then the signal gets raised. It might happen on only some platforms, and I can't even find back the page I was looking at when I read that. Maybe someone else knows? ChrisA