Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_testinternalcapi.assemble_code_object doesn't construct the exception table #115796

Closed
iritkatriel opened this issue Feb 22, 2024 · 0 comments · Fixed by #115797
Closed

_testinternalcapi.assemble_code_object doesn't construct the exception table #115796

iritkatriel opened this issue Feb 22, 2024 · 0 comments · Fixed by #115797
Assignees

Comments

@iritkatriel
Copy link
Member

iritkatriel commented Feb 22, 2024

The code object returned from _testinternalcapi.assemble_code_object. doesn't have a code object:

from _testinternalcapi import compiler_codegen, optimize_cfg, assemble_code_object

metadata = {
    'filename' : 'exc.py',
    'name'     : 'exc',
    'consts'   : {2 : 0},
}   
            
# code for "try: pass\n except: pass"
insts = [
    ('RESUME', 0),
    ('SETUP_FINALLY', 3),
    ('RETURN_CONST', 0),
    ('SETUP_CLEANUP', 8),
    ('PUSH_EXC_INFO', 0),
    ('POP_TOP', 0),               
    ('POP_EXCEPT', 0),
    ('RETURN_CONST', 0),
    ('COPY', 3),
    ('POP_EXCEPT', 0),
    ('RERAISE', 1),
]

from test.test_compiler_assemble import IsolatedAssembleTests
metadata = IsolatedAssembleTests().complete_metadata(metadata)  
insts = IsolatedAssembleTests().complete_insts_info(insts) 
co = assemble_code_object(metadata['filename'], insts, metadata)
print(co.co_exceptiontable)

Output:

b''

Linked PRs

@iritkatriel iritkatriel self-assigned this Feb 22, 2024
@iritkatriel iritkatriel changed the title _testinternalcapi.assemble_code_object. doesn't construct the exception table _testinternalcapi.assemble_code_object doesn't construct the exception table Feb 22, 2024
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Feb 22, 2024
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant