Skip to content

dis.disco()/dis.dis() does not show current line correctly with CACHE entries #103046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gaogaotiantian opened this issue Mar 26, 2023 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@gaogaotiantian
Copy link
Member

gaogaotiantian commented Mar 26, 2023

Now with CACHE entries, the lasti could point to a CACHE entry and current line indicator will be confused.

import dis

def f():
    print(a)
dis.disco(f.__code__, lasti=2)
dis.disco(f.__code__, lasti=4)

will display

  3           0 RESUME                   0

  4 -->       2 LOAD_GLOBAL              1 (NULL + print)
             14 LOAD_GLOBAL              2 (a)
             26 PRECALL                  1
             30 CALL                     1
             40 POP_TOP
             42 LOAD_CONST               0 (None)
             44 RETURN_VALUE
  3           0 RESUME                   0

  4           2 LOAD_GLOBAL              1 (NULL + print)
             14 LOAD_GLOBAL              2 (a)
             26 PRECALL                  1
             30 CALL                     1
             40 POP_TOP
             42 LOAD_CONST               0 (None)
             44 RETURN_VALUE

This is confusing for the users because they would probably not realize that there are CACHE entries. And with show_caches=False, we should show the current line to the instruction that the CACHE belongs to.

Linked PRs

@terryjreedy
Copy link
Member

@iritkatriel @markshannon Is above dis a bug? Is the short PR good?

warsaw pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants