[3.12] gh-116325: Raise SyntaxError rather than IndexError on ForwardRef with empty string arg (GH-116341) (#116347)

gh-116325: Raise `SyntaxError` rather than `IndexError` on ForwardRef with empty string arg (GH-116341)
(cherry picked from commit a29998a06b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2024-03-05 11:08:27 +01:00 committed by GitHub
parent 8785eab342
commit 6264c4f4b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View file

@ -5655,6 +5655,12 @@ class ForwardRefTests(BaseTestCase):
with self.assertRaises(SyntaxError):
get_type_hints(foo)
def test_syntax_error_empty_string(self):
for form in [typing.List, typing.Set, typing.Type, typing.Deque]:
with self.subTest(form=form):
with self.assertRaises(SyntaxError):
form['']
def test_name_error(self):
def foo(a: 'Noode[T]'):