[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-dev
Subject:    Re: [Python-Dev] PEP 310 and exceptions
From:       Nick Coghlan <ncoghlan () gmail ! com>
Date:       2005-04-24 1:22:17
Message-ID: 426AF4C9.6000008 () gmail ! com
[Download RAW message or body]

Bernhard Herzog wrote:
> With the proposed implementation of PEP 310 rev. 1.5 it wouldn't work.
> sys.exc_info returns a tuple of Nones unless an except: clause has been
> entered.  Either sys.exc_info() would have to be changed to always
> return exception information after an exception has been raised or the
> implementation would have to be changed to do the equivalent of e.g.

Interesting. Although the 'null' except block should probably be a bare 'raise', 
rather than a 'pass':

Py> try:
...   try:
...     raise TypeError("I'm an error!")
...   except:
...     raise
... finally:
...   print sys.exc_info()
...
(<class exceptions.TypeError at 0x009745A0>, <exceptions.TypeError instance at 0
x009E7238>, <traceback object at 0x009E72B0>)
Traceback (most recent call last):
   File "<stdin>", line 3, in ?
TypeError: I'm an error!

All the more reason to consider switching to a nested try/finally + 
try/except/else definition for 'with' blocks, I guess.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic