I have stumbled on a weird issue.
In a library, I assemble function bytecode manually using the bytecode library. Up to Python 3.11 everything works fine. In Python 3.12, I have one instance in which the following occurs:
- the function
__globals__attribute of a function contains a specific name (checked by instrumenting the bytecode)
- when calling that function this name cannot be retrieved and the globals dict actually differs from the function one (checked by instrumenting the bytecode)
I will try to make a minimal reproducer but it may not be easy and I wanted to know if anybody was aware of changes in 3.12 (optimization) that could lead to such an inconsistency ?