bug? context managers vs ImportErrors

Christian Heimes lists at cheimes.de
Thu Aug 19 15:50:24 EDT 2010


> Why is 'e' ending up as a string rather than the ImportError object?
> 
> This is with Python 2.6.5 if that makes a difference...

It's a known bug in Python 2.6 and earlier. See
http://docs.python.org/whatsnew/2.7.html#porting-to-python-2-7

Due to a bug in Python 2.6, the exc_value parameter to __exit__()
methods was often the string representation of the exception, not an
instance. This was fixed in 2.7, so exc_value will be an instance as
expected. (Fixed by Florent Xicluna; issue 7853.)




More information about the Python-list mailing list