Re: [Python-Dev] exception chaining

2012-01-23 Thread Łukasz Langa
Wiadomość napisana przez Georg Brandl w dniu 23 sty 2012, o godz. 21:18: > Am 23.01.2012 15:49, schrieb Łukasz Langa: > > [graphics] >> Pomyśl o środowisku naturalnym zanim wydrukujesz tę wiadomość! >> Please consider the environment before printing out this e-mail. > > Oh please?! Excuse me.

Re: [Python-Dev] exception chaining

2012-01-23 Thread Georg Brandl
Am 23.01.2012 15:49, schrieb Łukasz Langa: [graphics] > Pomyśl o środowisku naturalnym zanim wydrukujesz tę wiadomość! > Please consider the environment before printing out this e-mail. Oh please?! Georg ___ Python-Dev mailing list Python-Dev@python.o

Re: [Python-Dev] exception chaining

2012-01-23 Thread Łukasz Langa
Wiadomość napisana przez Ethan Furman w dniu 20 sty 2012, o godz. 21:05:The problem I have with 'raise x from None' is it puts 'from None' clear at the end of linefrom None raise SomeOtherError('etc.')Better yet:with nocontext(): raise SomeOtherError('etc.')But that's python-ideas territory ;)-- Be

Re: [Python-Dev] exception chaining

2012-01-20 Thread Terry Reedy
On 1/20/2012 7:40 PM, Steven D'Aprano wrote: Benjamin Peterson wrote: 2012/1/20 Terry Reedy : Since 'raise' means 're-raise the current error', 'raise as OtherError' means (clearly to me, anyway) 're-raise the current error as OtherError'. That doesn't make any sense. You're changing the exce

Re: [Python-Dev] exception chaining

2012-01-20 Thread Steven D'Aprano
Ethan Furman wrote: The question I have at the moment is: should `raise as` be an error if no exception is currently being handled? I think so. "raise as Spam" essentially means "raise Spam with the context set to None". That's actually only useful if the context otherwise wouldn't be None,

Re: [Python-Dev] exception chaining

2012-01-20 Thread Steven D'Aprano
Benjamin Peterson wrote: 2012/1/20 Terry Reedy : Since 'raise' means 're-raise the current error', 'raise as OtherError' means (clearly to me, anyway) 're-raise the current error as OtherError'. That doesn't make any sense. You're changing the exception completely not reraising it. I expect

Re: [Python-Dev] exception chaining

2012-01-20 Thread Benjamin Peterson
2012/1/20 Terry Reedy : > Since 'raise' means 're-raise the current error', 'raise as OtherError' > means (clearly to me, anyway) 're-raise the current error as OtherError'. That doesn't make any sense. You're changing the exception completely not reraising it. -- Regards, Benjamin _

Re: [Python-Dev] exception chaining

2012-01-20 Thread Ethan Furman
Georg Brandl wrote: Well, the "as" in "raise as" would be very easily overlooked too. In any case, I don't think the context suppression is the most important thing about the exception raising, so it doesn't need to stand out... Good point. ___ Pyth

Re: [Python-Dev] exception chaining

2012-01-20 Thread Terry Reedy
Since 'raise' means 're-raise the current error', 'raise as OtherError' means (clearly to me, anyway) 're-raise the current error as OtherError'. This is just what you want to be able to say. Since 'raise' without a current error results in a TypeError, so should 'raise as OtherError'. I would

Re: [Python-Dev] exception chaining

2012-01-20 Thread Georg Brandl
Am 20.01.2012 21:05, schrieb Ethan Furman: > Benjamin Peterson wrote: >> 2012/1/20 Ethan Furman : >>> Summary: >>> >>> Exception Chaining is cool, unless you are writing libraries that want to >>> transform from Exception X to Exception Y as the the previous exception >>> context is unnecessary, po

Re: [Python-Dev] exception chaining

2012-01-20 Thread Benjamin Peterson
2012/1/20 Ethan Furman : > Benjamin Peterson wrote: >> >> 2012/1/20 Ethan Furman : >>> >>> Summary: >>> >>> Exception Chaining is cool, unless you are writing libraries that want to >>> transform from Exception X to Exception Y as the the previous exception >>> context is unnecessary, potentially c

Re: [Python-Dev] exception chaining

2012-01-20 Thread Ethan Furman
Benjamin Peterson wrote: 2012/1/20 Ethan Furman : Summary: Exception Chaining is cool, unless you are writing libraries that want to transform from Exception X to Exception Y as the the previous exception context is unnecessary, potentially confusing, and cluttery (yup, just made that word up!)

Re: [Python-Dev] exception chaining

2012-01-20 Thread Benjamin Peterson
2012/1/20 Ethan Furman : > Summary: > > Exception Chaining is cool, unless you are writing libraries that want to > transform from Exception X to Exception Y as the the previous exception > context is unnecessary, potentially confusing, and cluttery (yup, just made > that word up!). > > For all the

[Python-Dev] exception chaining

2012-01-20 Thread Ethan Furman
Summary: Exception Chaining is cool, unless you are writing libraries that want to transform from Exception X to Exception Y as the the previous exception context is unnecessary, potentially confusing, and cluttery (yup, just made that word up!). For all the gory details, see http://bugs.pyt

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

[Python-Dev] Exception chaining and generator finalisation

2010-07-31 Thread Greg Ewing
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 clause, you get a double-barrelled traceback that first reports