Message293382
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:38 | Martin.Teichmann | set | recipients:
+ Martin.Teichmann, ncoghlan, serhiy.storchaka |
2017-05-10 06:29:38 | Martin.Teichmann | set | messageid: <1494397778.31.0.748800345983.issue30306@psf.upfronthosting.co.za> |
2017-05-10 06:29:38 | Martin.Teichmann | link | issue30306 messages |
2017-05-10 06:29:38 | Martin.Teichmann | create | |
|