Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unexpected IndexError in typing.List[''] #116325

Closed
Assignees
sobolevn
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or error
@jureslak

Description

@jureslak

Bug report

Bug description:

Callingtyping.List[''] produces an unexpectedIndexError.

>>>importtyping>>>typing.List['']Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/usr/lib/python3.11/typing.py",line362,ininnerreturncached(*args,**kwds)^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line1575,in__getitem__params=tuple(_type_check(p,msg)forpinparams)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line1575,in<genexpr>params=tuple(_type_check(p,msg)forpinparams)^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line186,in_type_checkarg=_type_convert(arg,module=module,allow_special_forms=allow_special_forms)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line164,in_type_convertreturnForwardRef(arg,module=module,is_class=allow_special_forms)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line859,in__init__ifarg[0]=='*':~~~^^^IndexError:stringindexoutofrange

The construct is invalid, but I'd expect a more friendly error, something similar to

>>>typing.Dict[1]Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/usr/lib/python3.11/typing.py",line365,ininnerreturnfunc(*args,**kwds)^^^^^^^^^^^^^^^^^^^File"/usr/lib/python3.11/typing.py",line1576,in__getitem___check_generic(self,params,self._nparams)File"/usr/lib/python3.11/typing.py",line293,in_check_genericraiseTypeError(f"Too{'many'ifalen>elenelse'few'} arguments for{cls};"TypeError:Toofewargumentsfortyping.Dict;actual1,expected2

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp