New submission from Henry Schreiner <henryschreiner...@gmail.com>:
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 <rep...@bugs.python.org> <https://bugs.python.org/issue46967> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com