[New-bugs-announce] [issue45108] frame.f_lasti points at DICT_MERGE instead of CALL_FUNCTION_EX in Windows only

Alex Hall report at bugs.python.org
Sun Sep 5 13:35:08 EDT 2021


New submission from Alex Hall <alex.mojaki at gmail.com>:

In this script:

    import inspect
    import dis
    
    def foo(**_):
        frame = inspect.currentframe().f_back
        print(frame.f_lasti)
        dis.dis(frame.f_code)
    
    d = {'a': 1, 'b': 2}
    foo(**d)

dis shows these instructions for `foo(**d)`:

 10          34 LOAD_NAME                2 (foo)
             36 BUILD_TUPLE              0
             38 BUILD_MAP                0
             40 LOAD_NAME                3 (d)
             42 DICT_MERGE               1
             44 CALL_FUNCTION_EX         1
             46 POP_TOP
             48 LOAD_CONST               1 (None)
             50 RETURN_VALUE

On Linux/OSX, frame.f_lasti is 44, pointing to the CALL_FUNCTION_EX as I'd expect.

But on Windows it's 42, which is the preceding instruction DICT_MERGE.

The bytecode itself is identical on the different systems, it's just the frame offset that differs.

This manifested as a test failure in a debugging tool here: https://github.com/samuelcolvin/python-devtools/pull/93

----------
components: Interpreter Core, Windows
messages: 401098
nosy: alexmojaki, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: frame.f_lasti points at DICT_MERGE instead of CALL_FUNCTION_EX in Windows only
type: behavior
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45108>
_______________________________________


More information about the New-bugs-announce mailing list