Closed thautwarm closed 6 years ago
I am not sure I understand your use case. Why do you need to create a second Bytecode object ? Can't you just modify the one you get after disassembling ? Before adding any new capabilities, I just prefer to be sure I understand your use case.
@MatthieuDartiailh Sorry, I've never thought about mutating the bytecode object directly! You've just reminded me and it works perfectly now! Thank you!
What I want to do is just replacing some instructions of a function's code object.
Happy we could figure this out.
Hi, community! This is such an awesome project that enable people to try something amazing in python, it does help me.
Currently, the following problem just troubled me:
I cannot correctly set the arguments now if I do not add
new_bc.argnames = bc.argnames
, for theBytecode
constructor doesn't have any other argument except aninstructions
. I wonder if I can rewrite the bytecode of a function and immediately create a new one with a constructor like:The new argument
metadata_from
could make the new code object consistent with the older one