When you decorate a function with contextmanager that didn't yield you got an AttributeError instead of a proper RuntimeError "generator didn't yield". For example:
>>> @contextlib.contextmanager >>> def foo(): ... pass ... >>> with foo(): ... do_something() ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() AttributeError: 'NoneType' object has no attribute 'next' The proper exception should be a RuntimerError with the "generator didn't yield" message. At least for Python version 2.7.6. Regards -- https://mail.python.org/mailman/listinfo/python-list