PEP 707: A simplified signature for __exit__ and __aexit__

Hello. I would like to take up this task because I’ve dealt in my work with the points @storchaka mentioned.

I wrote a pure Python gist which simulates the operation of a potential v2 context protocol - Python context manager protocol v2 · GitHub.

I don’t see how this can simplify writing re-entrant managers, because a re-entrant __enter__ call still needs to somehow know if it’s re-entrant or first call. But it still helps that we do not need to store __enter__ result in cases it is not just self.

I also have a few questions that will need to be resolved:

  1. Currently, if the manager returns an iterable object then with expr as (arg1, arg2) unpacks the result of expr.__enter__ immediately (e.g. with open(__file__) as (first_line, *lines). If the current use case is deprecated, then we need to consider that the existing code, after updating if exactly 2 values are used, will give not a syntax error, but very wrong behaviour. So, what alternatives to the syntax with expr as (enter_result, leave_result) could be?
  2. To indicate that the exception is not handled, in that gist __leave__ must raise it again, because it cannot just return an exception (as shown in the assertRaises example), and ‘any truthy value’ obviously may be the expected result. What were the reasons when creating the current context protocol to choose return False instead of raise exc_val?
  3. Currently, all uses of the expr as name idiom immediately bind the name, whereas leave_result binds only after leaving the block. Is this acceptable?

And the main question. Do I need to create a new discussion for this topic, and if so Ideas or core-dev?