Re: [Python-Dev] Exception chaining and generator finalisation

2010-08-01 Thread Greg Ewing
Nick Coghlan wrote: A toy example, that isn't obviously broken at first glance, but in fact fails when close() is called: Okay, you've convinced me. I'll consider it to be correct behaviour and update my expected yield-from test results accordingly. -- Greg ___

Re: [Python-Dev] Exception chaining and generator finalisation

2010-08-01 Thread Greg Ewing
Antoine Pitrou wrote: It only happens if you call close() explicitly: Well, that's only because the exception is being ignored and you're not getting a traceback at all. If you arrange to get a traceback, the same thing happens. import traceback as tb def g(): try: try:

Re: [Python-Dev] Exception chaining and generator finalisation

2010-07-31 Thread Nick Coghlan
On Sun, Aug 1, 2010 at 1:25 PM, Greg Ewing wrote: > Nick Coghlan wrote: > >> I don't see it as an implementation detail - it's part of the spec of >> generator finalisation in PEP 342 > > It doesn't seem like something you need to know in this > situation, though. All it tells you is that the fina

Re: [Python-Dev] Exception chaining and generator finalisation

2010-07-31 Thread Antoine Pitrou
On Sun, 01 Aug 2010 13:01:32 +1200 Greg Ewing wrote: > While updating my yield-from impementation for Python > 3.1.2, I came across a quirk in the way that the new > exception chaining feature interacts with generators. > > If you close() a generator, and it raises an exception > inside a finally

Re: [Python-Dev] Exception chaining and generator finalisation

2010-07-31 Thread Greg Ewing
Nick Coghlan wrote: I don't see it as an implementation detail - it's part of the spec of generator finalisation in PEP 342 It doesn't seem like something you need to know in this situation, though. All it tells you is that the finalisation is happening because the generator is being closed ra

Re: [Python-Dev] Exception chaining and generator finalisation

2010-07-31 Thread Nick Coghlan
On Sun, Aug 1, 2010 at 11:01 AM, Greg Ewing wrote: > While updating my yield-from impementation for Python > 3.1.2, I came across a quirk in the way that the new > exception chaining feature interacts with generators. > > If you close() a generator, and it raises an exception > inside a finally cl