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.

classification
Title: frame.f_lasti points at DICT_MERGE instead of CALL_FUNCTION_EX in Windows only
Type: behavior Stage:
Components: Interpreter Core, Windows Versions: Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: alexmojaki, iritkatriel, paul.moore, samuelcolvin, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2021-09-05 17:35 by alexmojaki, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg401098 - (view) Author: Alex Hall (alexmojaki) Date: 2021-09-05 17:35
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
msg401100 - (view) Author: Samuel Colvin (samuelcolvin) * Date: 2021-09-05 17:46
Perhaps worth adding that the tests don't fail on python 3.6, 3.7 or 3.8.
msg409335 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-29 23:57
I've reproduced this on 3.10 but in 3.11 the result on windows is correct, f_lasti is of the CALL_FUNCTION_EX opcode.
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89271
2021-12-29 23:57:55iritkatrielsetnosy: + iritkatriel
messages: + msg409335
2021-09-05 17:46:37samuelcolvinsetnosy: + samuelcolvin
messages: + msg401100
2021-09-05 17:35:08alexmojakicreate