]> granicus.if.org Git - python/commitdiff
Fix off-by-one errors in code to find depth of stack.
authorJeremy Hylton <jeremy@alum.mit.edu>
Wed, 29 Aug 2001 20:55:17 +0000 (20:55 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Wed, 29 Aug 2001 20:55:17 +0000 (20:55 +0000)
XXX The code is still widely inaccurate, but most (all?) of the time
it's an overestimate.

Lib/compiler/pyassem.py
Tools/compiler/compiler/pyassem.py

index b2f91aad1f921399e49e45f5040fb7516bb2c59e..413a954afd078bdaa01efa1d903624d8915af0fe 100644 (file)
@@ -764,11 +764,11 @@ class StackDepthTracker:
     # UNPACK_SEQUENCE, BUILD_TUPLE,
     # BUILD_LIST, CALL_FUNCTION, MAKE_FUNCTION, BUILD_SLICE
     def UNPACK_SEQUENCE(self, count):
-        return count
+        return count-1
     def BUILD_TUPLE(self, count):
-        return -count
+        return -count+1
     def BUILD_LIST(self, count):
-        return -count
+        return -count+1
     def CALL_FUNCTION(self, argc):
         hi, lo = divmod(argc, 256)
         return lo + hi * 2
index b2f91aad1f921399e49e45f5040fb7516bb2c59e..413a954afd078bdaa01efa1d903624d8915af0fe 100644 (file)
@@ -764,11 +764,11 @@ class StackDepthTracker:
     # UNPACK_SEQUENCE, BUILD_TUPLE,
     # BUILD_LIST, CALL_FUNCTION, MAKE_FUNCTION, BUILD_SLICE
     def UNPACK_SEQUENCE(self, count):
-        return count
+        return count-1
     def BUILD_TUPLE(self, count):
-        return -count
+        return -count+1
     def BUILD_LIST(self, count):
-        return -count
+        return -count+1
     def CALL_FUNCTION(self, argc):
         hi, lo = divmod(argc, 256)
         return lo + hi * 2