
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2015-10-13 09:27 byMartí Congost Tapias, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Messages (3) | |||
|---|---|---|---|
| msg252923 -(view) | Author: Martí Congost Tapias (Martí Congost Tapias) | Date: 2015-10-13 09:27 | |
Defining a union of typing.re.Pattern and anything that isn't AnyStr raises a TypeError exception.Example:from typing import Union, redef foo(pattern: Union[str, re.Pattern]) -> None: passException traceback:Traceback (most recent call last): File "/tmp/testtyping.py", line 7, in <module> def foo(pattern: Union[str, re.Pattern]) -> None: File "/usr/local/lib/python3.5/typing.py", line 534, in __getitem__ dict(self.__dict__), parameters, _root=True) File "/usr/local/lib/python3.5/typing.py", line 491, in __new__ for t2 in all_params - {t1} if not isinstance(t2, TypeVar)): File "/usr/local/lib/python3.5/typing.py", line 491, in <genexpr> for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):TypeError: issubclass() arg 1 must be a class | |||
| msg252937 -(view) | Author: Guido van Rossum (gvanrossum)*![]() | Date: 2015-10-13 15:54 | |
Confirmed. The failure is because Pattern is _TypeAlias, which is not a type. But it should be allowed. I'll think of something. (Does mypy accept this?) | |||
| msg253198 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2015-10-19 21:56 | |
New changeset955d3faf727a by Guido van Rossum in branch '3.5':Issue#25390: typing: Don't crash on Union[str, Pattern].https://hg.python.org/cpython/rev/955d3faf727aNew changeset04314479af0b by Guido van Rossum in branch 'default':Issue#25390: typing: Don't crash on Union[str, Pattern]. (Merge 3.5->3.6)https://hg.python.org/cpython/rev/04314479af0b | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:22 | admin | set | github: 69577 |
| 2015-10-19 21:57:04 | gvanrossum | set | status: open -> closed resolution: fixed |
| 2015-10-19 21:56:46 | python-dev | set | nosy: +python-dev messages: +msg253198 |
| 2015-10-13 15:54:58 | gvanrossum | set | assignee:gvanrossum |
| 2015-10-13 15:54:36 | gvanrossum | set | nosy: +gvanrossum messages: +msg252937 |
| 2015-10-13 13:05:52 | Martí Congost Tapias | set | components: + Library (Lib), - Interpreter Core |
| 2015-10-13 10:13:54 | xiang.zhang | set | nosy: +xiang.zhang |
| 2015-10-13 09:27:47 | Martí Congost Tapias | create | |