Skip to content
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

show_caches option affects code positions reported by dis.get_instructions(...) #91389

Open
15r10nk mannequin opened this issue Apr 5, 2022 · 8 comments
Open

show_caches option affects code positions reported by dis.get_instructions(...) #91389

15r10nk mannequin opened this issue Apr 5, 2022 · 8 comments
Labels
3.11 type-bug

Comments

@15r10nk
Copy link

@15r10nk 15r10nk mannequin commented Apr 5, 2022

BPO 47233
Nosy @brandtbucher, @15r10nk
PRs
  • #32406
  • Files
  • test2.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-04-05.19:47:24.937>
    labels = ['type-bug', '3.11']
    title = 'show_caches option affects code positions reported by dis.get_instructions(...)'
    updated_at = <Date 2022-04-07.20:52:49.864>
    user = 'https://github.com/15r10nk'

    bugs.python.org fields:

    activity = <Date 2022-04-07.20:52:49.864>
    actor = '15r10nk'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = []
    creation = <Date 2022-04-05.19:47:24.937>
    creator = '15r10nk'
    dependencies = []
    files = ['50722']
    hgrepos = []
    issue_num = 47233
    keywords = ['patch']
    message_count = 3.0
    messages = ['416810', '416828', '416944']
    nosy_count = 2.0
    nosy_names = ['brandtbucher', '15r10nk']
    pr_nums = ['32406']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue47233'
    versions = ['Python 3.11']

    @15r10nk
    Copy link
    Author

    @15r10nk 15r10nk mannequin commented Apr 5, 2022

    The Instructions reported by dis.get_instructions(...) and dis.Bytecode(...) have different positions depending on the value of their show_caches argument.

    test2.py reproduces the problem.

    @15r10nk 15r10nk mannequin added 3.11 type-bug labels Apr 5, 2022
    @brandtbucher
    Copy link

    @brandtbucher brandtbucher commented Apr 5, 2022

    Nice catch. The fix should be pretty simple: just move this line...

    positions = Positions(*next(co_positions, ()))

    ...up to the top of the for loop.

    Are you interested in working on this?

    @15r10nk
    Copy link
    Author

    @15r10nk 15r10nk mannequin commented Apr 7, 2022

    I moved the line.
    Is there anything else required? unittests?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @15r10nk
    Copy link

    @15r10nk 15r10nk commented Apr 20, 2022

    The problem was fixed with e590379.

    @brandtbucher
    Copy link

    @brandtbucher brandtbucher commented Apr 20, 2022

    Was it? I haven't run it yet, but that patch doesn't look like it fixed the issue (there's still an early continue at the top of the loop).

    @15r10nk
    Copy link

    @15r10nk 15r10nk commented Apr 20, 2022

    yes, I bisected it down to this commit.

    @15r10nk
    Copy link

    @15r10nk 15r10nk commented Apr 20, 2022

    wait, maybe cache_counter gets never >0 in my tests ... the bug might be still there.

    @15r10nk
    Copy link

    @15r10nk 15r10nk commented Apr 20, 2022

    I have verified that the cache_counter gets >0 in my tests.

    I think the CACHE instructions have no corresponding positions in co_positions. It always continues the loop if the cache_conter is > 0.

    I think the current implementation is has no bug.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 type-bug
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants