[issue46330] Simplify the signature of __exit__

2022-01-11 Thread Barry A. Warsaw
Change by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +AlexWaygood ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: Implementation and transition issues aside, I like this idea. People can mostly just use isinstance() checks to match one or more exception types. Also, the single argument form would work well with structural pattern matching: def __exit__(self,

[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Irit Katriel
Irit Katriel added the comment: If it takes *args we should assume that it expects the triplet rather than a single exception. It's not an edge case, it's very common to write __exit__ like that. -- ___ Python tracker

[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: Thanks, that would work in normal cases but can cause issues if __exit__ takes *args. Still, that may be enough of an edge case that we can get it to work. -- ___ Python tracker

[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Irit Katriel
Irit Katriel added the comment: I've outlined a different approach here: https://gist.github.com/iritkatriel/3927147548b10a7929cb0b680e3adc52 Basically, to add introspection capabilities in the C API so that the interpreter can find out whether __exit__ expects one or three args. --

[issue46330] Simplify the signature of __exit__

2022-01-10 Thread Jelle Zijlstra
New submission from Jelle Zijlstra : With Irit's recent changes (bpo-45711), the (typ, exc, tb) tuple is now always redundant with just exc. As a result, `__exit__` methods now should only need to accept a single argument. If we were designing the context manager protocol from scratch, we