Skip to content

Possible "hysteresis" in bytecode recompilation with 3.12 #125

Description

@P403n1x87

We've started investigating support for CPython 3.12 in our project that makes use of bytecode and we have observed a potential "hysteresis" in the following test

https://github.com/DataDog/dd-trace-py/blob/db7372d249de118a48b78d64327b9a903a388068/tests/debugging/function/test_store.py#L183-L206

The test is manipulating a bytecode object by adding extra instructions, and then removing them, in different orders. We want to check that we get an equal, albeit not identical, code object. Up until CPython 3.11 the last equality assertion would pass, but with 3.12 it fails. Using the dis module we can confirm that the bytecode content of the two code objects being tested is essentially the same, so the equality check must be failing for some other attribute(s) of the code object

Disassembly of original code object:
  5           0 RESUME                   0

  6           2 LOAD_FAST                0 (snafu)
              4 RETURN_VALUE
Disassembly of new code object:
  5           0 RESUME                   0

  6           2 LOAD_FAST                0 (snafu)
              4 RETURN_VALUE

For completeness, the function is defined as

def modulestuff(snafu):
    return snafu

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions