Skip to content

Add co_stacksize to code objects #4554

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

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,17 +851,13 @@ def compile_snippet(i):
self.fail("stack sizes diverge with # of consecutive snippets: "
"%s\n%s\n%s" % (sizes, snippet, out.getvalue()))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_if(self):
snippet = """
if x:
a
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_if_else(self):
snippet = """
if x:
Expand All @@ -873,8 +869,6 @@ def test_if_else(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_try_except_bare(self):
snippet = """
try:
Expand All @@ -884,8 +878,6 @@ def test_try_except_bare(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_try_except_qualified(self):
snippet = """
try:
Expand All @@ -899,8 +891,6 @@ def test_try_except_qualified(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_try_except_as(self):
snippet = """
try:
Expand All @@ -914,8 +904,6 @@ def test_try_except_as(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_try_finally(self):
snippet = """
try:
Expand All @@ -925,17 +913,13 @@ def test_try_finally(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_with(self):
snippet = """
with x as y:
a
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_while_else(self):
snippet = """
while x:
Expand All @@ -945,17 +929,13 @@ def test_while_else(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for(self):
snippet = """
for x in y:
a
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_else(self):
snippet = """
for x in y:
Expand All @@ -965,8 +945,6 @@ def test_for_else(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_break_continue(self):
snippet = """
for x in y:
Expand All @@ -981,8 +959,6 @@ def test_for_break_continue(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_break_continue_inside_try_finally_block(self):
snippet = """
for x in y:
Expand All @@ -1000,8 +976,6 @@ def test_for_break_continue_inside_try_finally_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_break_continue_inside_finally_block(self):
snippet = """
for x in y:
Expand All @@ -1019,8 +993,6 @@ def test_for_break_continue_inside_finally_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_break_continue_inside_except_block(self):
snippet = """
for x in y:
Expand All @@ -1038,8 +1010,6 @@ def test_for_break_continue_inside_except_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_break_continue_inside_with_block(self):
snippet = """
for x in y:
Expand All @@ -1055,8 +1025,6 @@ def test_for_break_continue_inside_with_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_return_inside_try_finally_block(self):
snippet = """
try:
Expand All @@ -1069,8 +1037,6 @@ def test_return_inside_try_finally_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_return_inside_finally_block(self):
snippet = """
try:
Expand All @@ -1083,8 +1049,6 @@ def test_return_inside_finally_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_return_inside_except_block(self):
snippet = """
try:
Expand All @@ -1097,8 +1061,6 @@ def test_return_inside_except_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_return_inside_with_block(self):
snippet = """
with c:
Expand All @@ -1109,26 +1071,20 @@ def test_return_inside_with_block(self):
"""
self.check_stack_size(snippet)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_async_with(self):
snippet = """
async with x as y:
a
"""
self.check_stack_size(snippet, async_=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_async_for(self):
snippet = """
async for x in y:
a
"""
self.check_stack_size(snippet, async_=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_async_for_else(self):
snippet = """
async for x in y:
Expand All @@ -1138,8 +1094,6 @@ def test_async_for_else(self):
"""
self.check_stack_size(snippet, async_=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_for_break_continue_inside_async_with_block(self):
snippet = """
for x in y:
Expand All @@ -1155,8 +1109,6 @@ def test_for_break_continue_inside_async_with_block(self):
"""
self.check_stack_size(snippet, async_=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_return_inside_async_with_block(self):
snippet = """
async with c:
Expand Down
5 changes: 5 additions & 0 deletions vm/src/builtins/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ impl PyRef<PyCode> {
self.code.arg_count
}

#[pygetset]
fn co_stacksize(self) -> u32 {
self.code.max_stackdepth
}

#[pygetset]
pub fn co_filename(self) -> PyStrRef {
self.code.source_path.to_owned()
Expand Down