Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9263848

Browse files
committed
Improve stack depth computation for try/except and try/finally
Add CONTINUE_LOOP to the list of unconditional transfers
1 parent 4bd4ddd commit 9263848

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Lib/compiler/pyassem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def addNext(self, block):
267267
assert len(self.next) == 1, map(str, self.next)
268268

269269
_uncond_transfer = ('RETURN_VALUE', 'RAISE_VARARGS',
270-
'JUMP_ABSOLUTE', 'JUMP_FORWARD')
270+
'JUMP_ABSOLUTE', 'JUMP_FORWARD', 'CONTINUE_LOOP')
271271

272272
def pruneNext(self):
273273
"""Remove bogus edge for unconditional transfers
@@ -753,6 +753,9 @@ def findDepth(self, insts):
753753
'IMPORT_STAR': -1,
754754
'IMPORT_NAME': 0,
755755
'IMPORT_FROM': 1,
756+
# close enough...
757+
'SETUP_EXCEPT': 3,
758+
'SETUP_FINALLY': 3,
756759
}
757760
# use pattern match
758761
patterns = [

Tools/compiler/compiler/pyassem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def addNext(self, block):
267267
assert len(self.next) == 1, map(str, self.next)
268268

269269
_uncond_transfer = ('RETURN_VALUE', 'RAISE_VARARGS',
270-
'JUMP_ABSOLUTE', 'JUMP_FORWARD')
270+
'JUMP_ABSOLUTE', 'JUMP_FORWARD', 'CONTINUE_LOOP')
271271

272272
def pruneNext(self):
273273
"""Remove bogus edge for unconditional transfers
@@ -753,6 +753,9 @@ def findDepth(self, insts):
753753
'IMPORT_STAR': -1,
754754
'IMPORT_NAME': 0,
755755
'IMPORT_FROM': 1,
756+
# close enough...
757+
'SETUP_EXCEPT': 3,
758+
'SETUP_FINALLY': 3,
756759
}
757760
# use pattern match
758761
patterns = [

0 commit comments

Comments
 (0)