You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trying to iterate over typing.Union results in hang #92261
As far as I can tell, this happens because typing.Union is implemented using typing._SpecialForm, and _SpecialForm is implemented using __getitem__ to support parameterisation like Union[int]. Unfortunately, because _SpecialForm doesn't implement __iter__, __getitem__ is also used for iteration - meaning that when trying to iterate, we effectively do Union[0], Union[1], etc.
Activity
JelleZijlstra commentedon May 3, 2022
We should deprecate
itertools.countbecause it's now redundant.More seriously, agree that we should disallow this.
gh-92261: Disallow iteration of Union (and other special forms) (GH-9…
mrahtz commentedon May 8, 2022
Fixed in 4739997.
pythongh-92261: Disallow iteration of Union (and other special forms) (…
gh-92261: Disallow iteration of Union (and other special forms) (GH-9…