mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-116325: Raise SyntaxError
rather than IndexError
on ForwardRef with empty string arg (#116341)
This commit is contained in:
parent
ffcc450a9b
commit
a29998a06b
3 changed files with 9 additions and 1 deletions
|
@ -880,7 +880,7 @@ class ForwardRef(_Final, _root=True):
|
|||
# If we do `def f(*args: *Ts)`, then we'll have `arg = '*Ts'`.
|
||||
# Unfortunately, this isn't a valid expression on its own, so we
|
||||
# do the unpacking manually.
|
||||
if arg[0] == '*':
|
||||
if arg.startswith('*'):
|
||||
arg_to_compile = f'({arg},)[0]' # E.g. (*Ts,)[0] or (*tuple[int, int],)[0]
|
||||
else:
|
||||
arg_to_compile = arg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue