◐ Shell
clean mode source ↗

Message 416498 - Python tracker

> See bpo-47185: code.replace(co_code=new_code) no longer catch exceptions on Python 3.11.

Surely the bigger issue is that the contents of new_code itself must be totally different? Also there are other tables that need to be adjusted if you really do change co_code, e.g. the debugging tables.