Skip to content

Commit 95e863c

Browse files
committed
Add co_stacksize to code objects
1 parent 6d71f75 commit 95e863c

File tree

2 files changed

+5
-48
lines changed

2 files changed

+5
-48
lines changed

Lib/test/test_compile.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -851,17 +851,13 @@ def compile_snippet(i):
851851
self.fail("stack sizes diverge with # of consecutive snippets: "
852852
"%s\n%s\n%s" % (sizes, snippet, out.getvalue()))
853853

854-
# TODO: RUSTPYTHON
855-
@unittest.expectedFailure
856854
def test_if(self):
857855
snippet = """
858856
if x:
859857
a
860858
"""
861859
self.check_stack_size(snippet)
862860

863-
# TODO: RUSTPYTHON
864-
@unittest.expectedFailure
865861
def test_if_else(self):
866862
snippet = """
867863
if x:
@@ -873,8 +869,6 @@ def test_if_else(self):
873869
"""
874870
self.check_stack_size(snippet)
875871

876-
# TODO: RUSTPYTHON
877-
@unittest.expectedFailure
878872
def test_try_except_bare(self):
879873
snippet = """
880874
try:
@@ -884,8 +878,6 @@ def test_try_except_bare(self):
884878
"""
885879
self.check_stack_size(snippet)
886880

887-
# TODO: RUSTPYTHON
888-
@unittest.expectedFailure
889881
def test_try_except_qualified(self):
890882
snippet = """
891883
try:
@@ -899,8 +891,6 @@ def test_try_except_qualified(self):
899891
"""
900892
self.check_stack_size(snippet)
901893

902-
# TODO: RUSTPYTHON
903-
@unittest.expectedFailure
904894
def test_try_except_as(self):
905895
snippet = """
906896
try:
@@ -914,8 +904,6 @@ def test_try_except_as(self):
914904
"""
915905
self.check_stack_size(snippet)
916906

917-
# TODO: RUSTPYTHON
918-
@unittest.expectedFailure
919907
def test_try_finally(self):
920908
snippet = """
921909
try:
@@ -925,17 +913,13 @@ def test_try_finally(self):
925913
"""
926914
self.check_stack_size(snippet)
927915

928-
# TODO: RUSTPYTHON
929-
@unittest.expectedFailure
930916
def test_with(self):
931917
snippet = """
932918
with x as y:
933919
a
934920
"""
935921
self.check_stack_size(snippet)
936922

937-
# TODO: RUSTPYTHON
938-
@unittest.expectedFailure
939923
def test_while_else(self):
940924
snippet = """
941925
while x:
@@ -945,17 +929,13 @@ def test_while_else(self):
945929
"""
946930
self.check_stack_size(snippet)
947931

948-
# TODO: RUSTPYTHON
949-
@unittest.expectedFailure
950932
def test_for(self):
951933
snippet = """
952934
for x in y:
953935
a
954936
"""
955937
self.check_stack_size(snippet)
956938

957-
# TODO: RUSTPYTHON
958-
@unittest.expectedFailure
959939
def test_for_else(self):
960940
snippet = """
961941
for x in y:
@@ -965,8 +945,6 @@ def test_for_else(self):
965945
"""
966946
self.check_stack_size(snippet)
967947

968-
# TODO: RUSTPYTHON
969-
@unittest.expectedFailure
970948
def test_for_break_continue(self):
971949
snippet = """
972950
for x in y:
@@ -981,8 +959,6 @@ def test_for_break_continue(self):
981959
"""
982960
self.check_stack_size(snippet)
983961

984-
# TODO: RUSTPYTHON
985-
@unittest.expectedFailure
986962
def test_for_break_continue_inside_try_finally_block(self):
987963
snippet = """
988964
for x in y:
@@ -1000,8 +976,6 @@ def test_for_break_continue_inside_try_finally_block(self):
1000976
"""
1001977
self.check_stack_size(snippet)
1002978

1003-
# TODO: RUSTPYTHON
1004-
@unittest.expectedFailure
1005979
def test_for_break_continue_inside_finally_block(self):
1006980
snippet = """
1007981
for x in y:
@@ -1019,8 +993,6 @@ def test_for_break_continue_inside_finally_block(self):
1019993
"""
1020994
self.check_stack_size(snippet)
1021995

1022-
# TODO: RUSTPYTHON
1023-
@unittest.expectedFailure
1024996
def test_for_break_continue_inside_except_block(self):
1025997
snippet = """
1026998
for x in y:
@@ -1038,8 +1010,6 @@ def test_for_break_continue_inside_except_block(self):
10381010
"""
10391011
self.check_stack_size(snippet)
10401012

1041-
# TODO: RUSTPYTHON
1042-
@unittest.expectedFailure
10431013
def test_for_break_continue_inside_with_block(self):
10441014
snippet = """
10451015
for x in y:
@@ -1055,8 +1025,6 @@ def test_for_break_continue_inside_with_block(self):
10551025
"""
10561026
self.check_stack_size(snippet)
10571027

1058-
# TODO: RUSTPYTHON
1059-
@unittest.expectedFailure
10601028
def test_return_inside_try_finally_block(self):
10611029
snippet = """
10621030
try:
@@ -1069,8 +1037,6 @@ def test_return_inside_try_finally_block(self):
10691037
"""
10701038
self.check_stack_size(snippet)
10711039

1072-
# TODO: RUSTPYTHON
1073-
@unittest.expectedFailure
10741040
def test_return_inside_finally_block(self):
10751041
snippet = """
10761042
try:
@@ -1083,8 +1049,6 @@ def test_return_inside_finally_block(self):
10831049
"""
10841050
self.check_stack_size(snippet)
10851051

1086-
# TODO: RUSTPYTHON
1087-
@unittest.expectedFailure
10881052
def test_return_inside_except_block(self):
10891053
snippet = """
10901054
try:
@@ -1097,8 +1061,6 @@ def test_return_inside_except_block(self):
10971061
"""
10981062
self.check_stack_size(snippet)
10991063

1100-
# TODO: RUSTPYTHON
1101-
@unittest.expectedFailure
11021064
def test_return_inside_with_block(self):
11031065
snippet = """
11041066
with c:
@@ -1109,26 +1071,20 @@ def test_return_inside_with_block(self):
11091071
"""
11101072
self.check_stack_size(snippet)
11111073

1112-
# TODO: RUSTPYTHON
1113-
@unittest.expectedFailure
11141074
def test_async_with(self):
11151075
snippet = """
11161076
async with x as y:
11171077
a
11181078
"""
11191079
self.check_stack_size(snippet, async_=True)
11201080

1121-
# TODO: RUSTPYTHON
1122-
@unittest.expectedFailure
11231081
def test_async_for(self):
11241082
snippet = """
11251083
async for x in y:
11261084
a
11271085
"""
11281086
self.check_stack_size(snippet, async_=True)
11291087

1130-
# TODO: RUSTPYTHON
1131-
@unittest.expectedFailure
11321088
def test_async_for_else(self):
11331089
snippet = """
11341090
async for x in y:
@@ -1138,8 +1094,6 @@ def test_async_for_else(self):
11381094
"""
11391095
self.check_stack_size(snippet, async_=True)
11401096

1141-
# TODO: RUSTPYTHON
1142-
@unittest.expectedFailure
11431097
def test_for_break_continue_inside_async_with_block(self):
11441098
snippet = """
11451099
for x in y:
@@ -1155,8 +1109,6 @@ def test_for_break_continue_inside_async_with_block(self):
11551109
"""
11561110
self.check_stack_size(snippet, async_=True)
11571111

1158-
# TODO: RUSTPYTHON
1159-
@unittest.expectedFailure
11601112
def test_return_inside_async_with_block(self):
11611113
snippet = """
11621114
async with c:

vm/src/builtins/code.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ impl PyRef<PyCode> {
213213
self.code.arg_count
214214
}
215215

216+
#[pygetset]
217+
fn co_stacksize(self) -> u32 {
218+
self.code.max_stackdepth
219+
}
220+
216221
#[pygetset]
217222
pub fn co_filename(self) -> PyStrRef {
218223
self.code.source_path.to_owned()

0 commit comments

Comments
 (0)