[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-05 Thread STINNER Victor
STINNER Victor added the comment: Ok sure, I created bpo-47236 "Document types.CodeType.replace() changes about co_exceptiontable". -- ___ Python tracker ___

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-05 Thread Guido van Rossum
Guido van Rossum added the comment: If you think the changes to .replace() should be documented just open a new bpo. You made this issue about your various proposals to change .replace(). -- ___ Python tracker

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-05 Thread STINNER Victor
STINNER Victor added the comment: >>> def f(): ... foo() ... try: ... bar() ... except: ... pass ... >>> def g(): ... try: ... foo() ... bar() ... except: ... pass ... >>> dis.dis(f) 1 0 RESUME 0 2

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-05 Thread Guido van Rossum
Guido van Rossum added the comment: This idea just cannot work. Take these two functions: def f(): foo() try: bar() except: pass def g(): try: foo() bar() except: pass Using dis to look at their disassembly, the only hint that in

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-05 Thread Gregory P. Smith
Change by Gregory P. Smith : -- nosy: +gregory.p.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-03 Thread Guido van Rossum
Guido van Rossum 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

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-03 Thread Dominic Davis-Foster
Change by Dominic Davis-Foster : -- nosy: +dom1310df ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-01 Thread STINNER Victor
STINNER Victor 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

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-01 Thread STINNER Victor
STINNER Victor added the comment: python-dev thread: https://mail.python.org/archives/list/python-...@python.org/thread/KWSPCLXDHBAP2U4LBSMLQEOC7LREDMPB/ Mark wrote: "You can pass the exception table the same way you pass all the other arguments. The exception table depends on the code, but

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-01 Thread STINNER Victor
STINNER Victor added the comment: > How would you compute the exception table from the bytecode? There are no > clues in the bytecode about where the try and except blocks are. Disassemble the bytecode to rebuild basic blocks and detect which ones are except blocks. I don't know how the

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-01 Thread Guido van Rossum
Guido van Rossum added the comment: How would you compute the exception table from the bytecode? There are no clues in the bytecode about where the try and except blocks are. -- nosy: +gvanrossum ___ Python tracker

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-01 Thread Eric Snow
Change by Eric Snow : -- nosy: +Mark.Shannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47185] code.replace(co_code=new_code) no longer catch exceptions on Python 3.11

2022-04-01 Thread STINNER Victor
New submission from STINNER Victor : Since bpo-40222 "Zero cost exception handling", code object created by from bytecode with code.replace(co_code=new_code) no longer catch exceptions on Python 3.11, unless an exception table is set explicitly. Example: --- def f(): try: