This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ellingtonjp
Recipients ellingtonjp, rhettinger
Date 2016-05-24.03:28:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464060517.76.0.559675330412.issue27100@psf.upfronthosting.co.za>
In-reply-to
Content
Attempting to use class that has both __exit__() and __enter__() undefined as a context manager yields an AttributeError referring to __exit__:

>>> class A():
...     pass
...
>>> with A():
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: A instance has no attribute '__exit__'


Knowing that the 'with' statement should first execute __enter__, this is unexpected.

The patch ensures the attribute error refers to __enter__() when both methods are undefined.
History
Date User Action Args
2016-05-24 03:28:37ellingtonjpsetrecipients: + ellingtonjp, rhettinger
2016-05-24 03:28:37ellingtonjpsetmessageid: <1464060517.76.0.559675330412.issue27100@psf.upfronthosting.co.za>
2016-05-24 03:28:37ellingtonjplinkissue27100 messages
2016-05-24 03:28:37ellingtonjpcreate