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 <>
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.
Date User Action Args
2017-05-10 06:29:38Martin.Teichmannsetrecipients: + Martin.Teichmann, ncoghlan, serhiy.storchaka
2017-05-10 06:29:38Martin.Teichmannsetmessageid: <>
2017-05-10 06:29:38Martin.Teichmannlinkissue30306 messages
2017-05-10 06:29:38Martin.Teichmanncreate