[proxy] bugs.python.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

Issue 28317: Improve support of FORMAT_VALUE in dis

FORMAT_VALUE packs the information about conversion flags and boolean flag that denotes whether format specifier is passed on the stack in one integer argument. It is not easy to decode this information in disassemble output. Proposed patch makes disassembler producing human readable representation of FORMAT_VALUE argument.

$ echo 'f"{a} {b:4} {c!r} {d!r:4}"' | ./python -m dis
  1           0 LOAD_NAME                0 (a)
              2 FORMAT_VALUE             0
              4 LOAD_CONST               0 (' ')
              6 LOAD_NAME                1 (b)
              8 LOAD_CONST               1 ('4')
             10 FORMAT_VALUE             4 (with format)
             12 LOAD_CONST               0 (' ')
             14 LOAD_NAME                2 (c)
             16 FORMAT_VALUE             2 (repr)
             18 LOAD_CONST               0 (' ')
             20 LOAD_NAME                3 (d)
             22 LOAD_CONST               1 ('4')
             24 FORMAT_VALUE             6 (repr, with format)
             26 BUILD_STRING             7
             28 POP_TOP
             30 LOAD_CONST               2 (None)
             32 RETURN_VALUE