Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'ignored': 0.07; 'except:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'subject:How': 0.10; 'def': 0.12; 'jan': 0.12; 'clause,': 0.16; 'closed:': 0.16; 'marco': 0.16; 'reason?': 0.16; 'reasonable.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'systemexit': 0.16; 'exception': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; '(in': 0.22; 'header:User-Agent:1': 0.23; 'switched': 0.24; 'why.': 0.24; 'nearly': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'raise': 0.29; '"",': 0.31; 'file': 0.32; '(most': 0.33; 'maybe': 0.34; 'except': 0.35; 'but': 0.35; 'there': 0.35; '2.6': 0.36; 'yield': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'catch': 0.60; 'received:173': 0.61; 'first': 0.61; 'details': 0.65; 'introduction': 0.68; '2.5.': 0.84; 'received:fios.verizon.net': 0.84; 'subject:skip:S 20': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: How come StopIteration.__base__ is not BaseException? Date: Tue, 27 Aug 2013 16:37:05 -0400 References: <521C446B.9040605@gmail.com> <521c6fb9$0$11100$c3e8da3@news.astraweb.com> <521C7935.8080205@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377635844 news.xs4all.nl 15948 [2001:888:2000:d::a6]:35174 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53092 On 8/27/2013 3:52 PM, Marco Buttu wrote: > On 08/27/2013 08:51 PM, Terry Reedy wrote: > >> BaseException was added just so it would be possible to catch nearly >> everything but a few exceptions. The first two were KeyboardInterrupt >> and SystemExit (in 2.5). GeneratorExit was switched in 2.6, but I forget >> the details of why. > > Maybe in order to don't catch it inside a generator using a except > Exception clause, because it is used to notify an active generator is > closed: > > >>> def foogen(): > ... for i in range(10): > ... try: > ... yield i > ... except: > ... print('Catched!') > ... # raise > ... > >>> g = foogen() > >>> next(g) > 0 > >>> g.close() > Catched! > Traceback (most recent call last): > File "", line 1, in > RuntimeError: generator ignored GeneratorExit > > Do you remember if this is the reason? Thanks, I only remember that there was a 'problem' that necessitated a change in 2.6 after the introduction in 2.5. The above seems reasonable. -- Terry Jan Reedy