mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-42737: annotations with complex targets no longer causes any runtime effects (GH-23952)
This commit is contained in:
parent
196983563d
commit
8cc3cfa8af
4 changed files with 23 additions and 0 deletions
|
@ -134,8 +134,12 @@ class AnnotationsFutureTestCase(unittest.TestCase):
|
|||
...
|
||||
async def g2(arg: {ann}) -> None:
|
||||
...
|
||||
class H:
|
||||
var: {ann}
|
||||
object.attr: {ann}
|
||||
var: {ann}
|
||||
var2: {ann} = None
|
||||
object.attr: {ann}
|
||||
"""
|
||||
)
|
||||
|
||||
|
@ -343,6 +347,13 @@ class AnnotationsFutureTestCase(unittest.TestCase):
|
|||
self.assertAnnotationEqual("('inf', 1e1000, 'infxxx', 1e1000j)", expected=f"('inf', {inf}, 'infxxx', {infj})")
|
||||
self.assertAnnotationEqual("(1e1000, (1e1000j,))", expected=f"({inf}, ({infj},))")
|
||||
|
||||
def test_annotation_with_complex_target(self):
|
||||
with self.assertRaises(SyntaxError):
|
||||
exec(
|
||||
"from __future__ import annotations\n"
|
||||
"object.__debug__: int"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue