[issue46967] Type union for except

2022-03-13 Thread Irit Katriel


Irit Katriel  added the comment:

> I don't think that `except A|B` looks better than `except (A, B)`

I agree.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46967] Type union for except

2022-03-09 Thread Guido van Rossum


Guido van Rossum  added the comment:

I don't think that `except A|B` looks better than `except (A, B)`, so I am 
against this proposal. Exception matching is its own special thing (e.g. it 
doesn't honor virtual subclasses) and we shouldn't hyper-generalize.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46967] Type union for except

2022-03-09 Thread Steven D'Aprano


Change by Steven D'Aprano :


--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46967] Type union for except

2022-03-09 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

This would be nice but I'm not sure it's worth the hassle in terms of 
documentation, tooling support, etc.

There is an existing issue (that I can't find right now) that makes the 
`except` machinery use `__instancecheck__`, instead of looking only at real 
base classes like it does now. That change would automatically also make `|` 
work.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46967] Type union for except

2022-03-09 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood, Jelle Zijlstra, gvanrossum, iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46967] Type union for except

2022-03-09 Thread Henry Schreiner


New submission from Henry Schreiner :

In 3.10 via PEP 604, there was an attempt to use the new union of types where 
runtime types were previously expected to be a tuple. `isinstance(x, (A, B))` 
can be written `isinstance(x, A | B)`. Unfortunately, there still is a case 
were a tuple of types is required: `except (A, B) as err:` cannot be written 
`except A | B as err:`. I think this should be allowed; it is consistent with 
isinstance and pattern matching's use of |, and nicely avoids confusion with 
`except A, B:` which is disallowed for Python 2 reasons; `except A | B`: would 
be valid.

--
components: Interpreter Core
messages: 414807
nosy: Henry Schreiner
priority: normal
severity: normal
status: open
title: Type union for except
type: enhancement
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com