Guido van Rossum <gu...@python.org> added the comment:
[Victor] > Do you consider that .replace() must reject changing co_code if other tables > are not updated? I simply don't believe it can always do that correctly, so I believe it should not do it. > Debugging tables are not strictly required just to *execute* code, no? No, but if they are wrong crashes might happen when they are consulted. At the very least they would confuse users. > 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). No. There are a zillion use cases. If you are using .replace() you are taking responsibility for the result. > 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). Where would these people get the value that they're using to replace co_code? Surely if they are generating bytecode it will already be broken. Pretty much all instructions are different in 3.11. ---------- _______________________________________ 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