Message391544
Hum, there seems to be an actual bug here: even with PEP 563, the annotations for "complex targets" are evaluated. For example:
from __future__ import annotations
class C:
x.y: z.w
a: b.c
The relevant parts of the disassembly of the code for the class object are:
3 10 LOAD_NAME 3 (x)
12 POP_TOP
14 LOAD_NAME 4 (z)
16 LOAD_ATTR 5 (w)
18 POP_TOP
4 20 LOAD_CONST 1 ('b.c')
22 LOAD_NAME 6 (__annotations__)
24 LOAD_CONST 2 ('a')
26 STORE_SUBSCR
So for x.y: z.w, not only do we evaluate x, we also evaluate z.w; whereas b.c is not evaluated (the stringified version is added as __annotations__['a']).
I think the "LOAD_NAME(x), POP_TOP" part is correct, but "LOAD_NAME(z), LOAD_ATTR(w), POP_TOP" should not be generated at all. |
|
Date |
User |
Action |
Args |
2021-04-21 21:24:25 | gvanrossum | set | recipients:
+ gvanrossum, serhiy.storchaka, lys.nikolaou, pablogsal, BTaskaya, gousaiyang |
2021-04-21 21:24:25 | gvanrossum | set | messageid: <1619040265.13.0.967676037694.issue42737@roundup.psfhosted.org> |
2021-04-21 21:24:25 | gvanrossum | link | issue42737 messages |
2021-04-21 21:24:24 | gvanrossum | create | |
|