Skip to content

Commit efa879e

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

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

Lib/test/test_compile.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,6 @@ def test_and_or(self):
811811
def test_chained_comparison(self):
812812
self.check_stack_size("x < " * self.N + "x")
813813

814-
# TODO: RUSTPYTHON
815-
@unittest.expectedFailure
816814
def test_if_else(self):
817815
self.check_stack_size("x if x else " * self.N + "x")
818816

@@ -851,17 +849,13 @@ def compile_snippet(i):
851849
self.fail("stack sizes diverge with # of consecutive snippets: "
852850
"%s\n%s\n%s" % (sizes, snippet, out.getvalue()))
853851

854-
# TODO: RUSTPYTHON
855-
@unittest.expectedFailure
856852
def test_if(self):
857853
snippet = """
858854
if x:
859855
a
860856
"""
861857
self.check_stack_size(snippet)
862858

863-
# TODO: RUSTPYTHON
864-
@unittest.expectedFailure
865859
def test_if_else(self):
866860
snippet = """
867861
if x:
@@ -873,8 +867,6 @@ def test_if_else(self):
873867
"""
874868
self.check_stack_size(snippet)
875869

876-
# TODO: RUSTPYTHON
877-
@unittest.expectedFailure
878870
def test_try_except_bare(self):
879871
snippet = """
880872
try:
@@ -884,8 +876,6 @@ def test_try_except_bare(self):
884876
"""
885877
self.check_stack_size(snippet)
886878

887-
# TODO: RUSTPYTHON
888-
@unittest.expectedFailure
889879
def test_try_except_qualified(self):
890880
snippet = """
891881
try:
@@ -899,8 +889,6 @@ def test_try_except_qualified(self):
899889
"""
900890
self.check_stack_size(snippet)
901891

902-
# TODO: RUSTPYTHON
903-
@unittest.expectedFailure
904892
def test_try_except_as(self):
905893
snippet = """
906894
try:
@@ -914,8 +902,6 @@ def test_try_except_as(self):
914902
"""
915903
self.check_stack_size(snippet)
916904

917-
# TODO: RUSTPYTHON
918-
@unittest.expectedFailure
919905
def test_try_finally(self):
920906
snippet = """
921907
try:
@@ -925,17 +911,13 @@ def test_try_finally(self):
925911
"""
926912
self.check_stack_size(snippet)
927913

928-
# TODO: RUSTPYTHON
929-
@unittest.expectedFailure
930914
def test_with(self):
931915
snippet = """
932916
with x as y:
933917
a
934918
"""
935919
self.check_stack_size(snippet)
936920

937-
# TODO: RUSTPYTHON
938-
@unittest.expectedFailure
939921
def test_while_else(self):
940922
snippet = """
941923
while x:
@@ -945,17 +927,13 @@ def test_while_else(self):
945927
"""
946928
self.check_stack_size(snippet)
947929

948-
# TODO: RUSTPYTHON
949-
@unittest.expectedFailure
950930
def test_for(self):
951931
snippet = """
952932
for x in y:
953933
a
954934
"""
955935
self.check_stack_size(snippet)
956936

957-
# TODO: RUSTPYTHON
958-
@unittest.expectedFailure
959937
def test_for_else(self):
960938
snippet = """
961939
for x in y:
@@ -965,8 +943,6 @@ def test_for_else(self):
965943
"""
966944
self.check_stack_size(snippet)
967945

968-
# TODO: RUSTPYTHON
969-
@unittest.expectedFailure
970946
def test_for_break_continue(self):
971947
snippet = """
972948
for x in y:
@@ -981,8 +957,6 @@ def test_for_break_continue(self):
981957
"""
982958
self.check_stack_size(snippet)
983959

984-
# TODO: RUSTPYTHON
985-
@unittest.expectedFailure
986960
def test_for_break_continue_inside_try_finally_block(self):
987961
snippet = """
988962
for x in y:
@@ -1000,8 +974,6 @@ def test_for_break_continue_inside_try_finally_block(self):
1000974
"""
1001975
self.check_stack_size(snippet)
1002976

1003-
# TODO: RUSTPYTHON
1004-
@unittest.expectedFailure
1005977
def test_for_break_continue_inside_finally_block(self):
1006978
snippet = """
1007979
for x in y:
@@ -1019,8 +991,6 @@ def test_for_break_continue_inside_finally_block(self):
1019991
"""
1020992
self.check_stack_size(snippet)
1021993

1022-
# TODO: RUSTPYTHON
1023-
@unittest.expectedFailure
1024994
def test_for_break_continue_inside_except_block(self):
1025995
snippet = """
1026996
for x in y:
@@ -1038,8 +1008,6 @@ def test_for_break_continue_inside_except_block(self):
10381008
"""
10391009
self.check_stack_size(snippet)
10401010

1041-
# TODO: RUSTPYTHON
1042-
@unittest.expectedFailure
10431011
def test_for_break_continue_inside_with_block(self):
10441012
snippet = """
10451013
for x in y:
@@ -1055,8 +1023,6 @@ def test_for_break_continue_inside_with_block(self):
10551023
"""
10561024
self.check_stack_size(snippet)
10571025

1058-
# TODO: RUSTPYTHON
1059-
@unittest.expectedFailure
10601026
def test_return_inside_try_finally_block(self):
10611027
snippet = """
10621028
try:
@@ -1069,8 +1035,6 @@ def test_return_inside_try_finally_block(self):
10691035
"""
10701036
self.check_stack_size(snippet)
10711037

1072-
# TODO: RUSTPYTHON
1073-
@unittest.expectedFailure
10741038
def test_return_inside_finally_block(self):
10751039
snippet = """
10761040
try:
@@ -1083,8 +1047,6 @@ def test_return_inside_finally_block(self):
10831047
"""
10841048
self.check_stack_size(snippet)
10851049

1086-
# TODO: RUSTPYTHON
1087-
@unittest.expectedFailure
10881050
def test_return_inside_except_block(self):
10891051
snippet = """
10901052
try:
@@ -1097,8 +1059,6 @@ def test_return_inside_except_block(self):
10971059
"""
10981060
self.check_stack_size(snippet)
10991061

1100-
# TODO: RUSTPYTHON
1101-
@unittest.expectedFailure
11021062
def test_return_inside_with_block(self):
11031063
snippet = """
11041064
with c:
@@ -1109,26 +1069,20 @@ def test_return_inside_with_block(self):
11091069
"""
11101070
self.check_stack_size(snippet)
11111071

1112-
# TODO: RUSTPYTHON
1113-
@unittest.expectedFailure
11141072
def test_async_with(self):
11151073
snippet = """
11161074
async with x as y:
11171075
a
11181076
"""
11191077
self.check_stack_size(snippet, async_=True)
11201078

1121-
# TODO: RUSTPYTHON
1122-
@unittest.expectedFailure
11231079
def test_async_for(self):
11241080
snippet = """
11251081
async for x in y:
11261082
a
11271083
"""
11281084
self.check_stack_size(snippet, async_=True)
11291085

1130-
# TODO: RUSTPYTHON
1131-
@unittest.expectedFailure
11321086
def test_async_for_else(self):
11331087
snippet = """
11341088
async for x in y:
@@ -1138,8 +1092,6 @@ def test_async_for_else(self):
11381092
"""
11391093
self.check_stack_size(snippet, async_=True)
11401094

1141-
# TODO: RUSTPYTHON
1142-
@unittest.expectedFailure
11431095
def test_for_break_continue_inside_async_with_block(self):
11441096
snippet = """
11451097
for x in y:
@@ -1155,8 +1107,6 @@ def test_for_break_continue_inside_async_with_block(self):
11551107
"""
11561108
self.check_stack_size(snippet, async_=True)
11571109

1158-
# TODO: RUSTPYTHON
1159-
@unittest.expectedFailure
11601110
def test_return_inside_async_with_block(self):
11611111
snippet = """
11621112
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)