This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients BTaskaya, gousaiyang, gvanrossum, lys.nikolaou, pablogsal, serhiy.storchaka
Date 2021-04-21.21:24:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:25gvanrossumsetrecipients: + gvanrossum, serhiy.storchaka, lys.nikolaou, pablogsal, BTaskaya, gousaiyang
2021-04-21 21:24:25gvanrossumsetmessageid: <>
2021-04-21 21:24:25gvanrossumlinkissue42737 messages
2021-04-21 21:24:24gvanrossumcreate