STINNER Victor <vstin...@python.org> added the comment:
Guido (msg416498) > 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. Do you consider that .replace() must reject changing co_code if other tables are not updated? Debugging tables are not strictly required just to *execute* code, no? If you consider that the caller *must* update co_exceptiontable, replace() must raise an exception in this case, to prevent creating a code object which would behave in a strange way (broken exception handling). If someone really wants testing an empty exception table just for fun, it would still be possible to pass co_exceptiontable=b''. My concern is more about people upgrading to Python 3.11 and who "suddenly" don't get their exceptions handled anymore. I would prefer catching such bug at the replace() call, rather than having to execute the code (and only notice the bug in production? oops). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47185> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com