[Python-Dev] [Python-checkins] r88331 - in python/branches/py3k/Doc/howto: index.rst pyporting.rst
Steven D'Aprano
steve at pearwood.info
Fri Feb 4 00:32:20 CET 2011
Nick Coghlan wrote:
> On Fri, Feb 4, 2011 at 8:01 AM, brett.cannon <python-checkins at python.org> wrote:
>> +Capturing the Currently Raised Exception
>> +----------------------------------------
>> +One change between Python 2 and 3 that will require changing how you code is
>> +accessing the currently raised exception. In Python 2 the syntax to access the
>> +current exception is::
I think that the semantic change is *much* more important that the
syntax change.
In 2.6:
>>> try:
... len(None)
... except TypeError as e:
... pass
...
>>> e
TypeError("object of type 'NoneType' has no len()",)
In 3.1:
>>> try:
... len(None)
... except TypeError as e:
... pass
...
>>> e
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'e' is not defined
--
Steven
More information about the Python-Dev
mailing list