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 Martin.Teichmann
Recipients Martin.Teichmann, ncoghlan, serhiy.storchaka
Date 2017-05-10.06:29:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1494397778.31.0.748800345983.issue30306@psf.upfronthosting.co.za>
In-reply-to
Content
I personally prefer the current situation. The problem is the following: when an @contextmanager is first called, we don't know yet whether the user wants to use it directly, or as a decorator, so we have to have some kind of hybrid class. Once it's used as a decorator, we need to recreate a context manager every time the decorate function is called. Then we need exactly the direct context manager mentioned above. This is why we recreate it with __class__.

In my MR on github I simplify that by not recreating the entire context manager, but only the generator function. I think this is the most clear way, as it shows what's going on in a confined area of code.
History
Date User Action Args
2017-05-10 06:29:38Martin.Teichmannsetrecipients: + Martin.Teichmann, ncoghlan, serhiy.storchaka
2017-05-10 06:29:38Martin.Teichmannsetmessageid: <1494397778.31.0.748800345983.issue30306@psf.upfronthosting.co.za>
2017-05-10 06:29:38Martin.Teichmannlinkissue30306 messages
2017-05-10 06:29:38Martin.Teichmanncreate