bug? context managers vs ImportErrors
Chris Withers
chris at simplistix.co.uk
Thu Aug 19 11:58:30 EDT 2010
Hi All,
Am I right in thinking this is a bug:
class MyContextManager:
def __enter__(self):
pass
def __exit__(self,t,e,tb):
print type(t),t
print type(e),e
with MyContextManager():
import foo.bar.baz
...when executed, gives me:
<type 'type'> <type 'exceptions.ImportError'>
<type 'str'> No module named foo.bar.baz
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...
Chris
More information about the Python-list
mailing list