This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Mark.Shannon, gvanrossum, vstinner
Date 2022-04-01.20:38:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648845526.82.0.282401294912.issue47185@roundup.psfhosted.org>
In-reply-to
Content
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).
History
Date User Action Args
2022-04-01 20:38:46vstinnersetrecipients: + vstinner, gvanrossum, Mark.Shannon
2022-04-01 20:38:46vstinnersetmessageid: <1648845526.82.0.282401294912.issue47185@roundup.psfhosted.org>
2022-04-01 20:38:46vstinnerlinkissue47185 messages
2022-04-01 20:38:46vstinnercreate