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

Skip to content

Commit 4ba9001

Browse files
committed
Fix off-by-one errors in code to find depth of stack.
XXX The code is still widely inaccurate, but most (all?) of the time it's an overestimate.
1 parent 8779787 commit 4ba9001

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Lib/compiler/pyassem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,11 @@ def findDepth(self, insts):
764764
# UNPACK_SEQUENCE, BUILD_TUPLE,
765765
# BUILD_LIST, CALL_FUNCTION, MAKE_FUNCTION, BUILD_SLICE
766766
def UNPACK_SEQUENCE(self, count):
767-
return count
767+
return count-1
768768
def BUILD_TUPLE(self, count):
769-
return -count
769+
return -count+1
770770
def BUILD_LIST(self, count):
771-
return -count
771+
return -count+1
772772
def CALL_FUNCTION(self, argc):
773773
hi, lo = divmod(argc, 256)
774774
return lo + hi * 2

Tools/compiler/compiler/pyassem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,11 @@ def findDepth(self, insts):
764764
# UNPACK_SEQUENCE, BUILD_TUPLE,
765765
# BUILD_LIST, CALL_FUNCTION, MAKE_FUNCTION, BUILD_SLICE
766766
def UNPACK_SEQUENCE(self, count):
767-
return count
767+
return count-1
768768
def BUILD_TUPLE(self, count):
769-
return -count
769+
return -count+1
770770
def BUILD_LIST(self, count):
771-
return -count
771+
return -count+1
772772
def CALL_FUNCTION(self, argc):
773773
hi, lo = divmod(argc, 256)
774774
return lo + hi * 2

0 commit comments

Comments
 (0)