[Python-checkins] python/dist/src/Lib pickletools.py,1.22,1.23
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 30 Jan 2003 07:02:17 -0800
- Previous message: [Python-checkins] python/nondist/sandbox/doctools README,1.2,NONE htmldoc.py,1.2,NONE inspect.py,1.1,NONE onlinehelp.py,1.4,NONE textdoc.py,1.1,NONE
- Next message: [Python-checkins] python/dist/src/Python modsupport.c,2.63,2.64
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv4758/Lib
Modified Files:
pickletools.py
Log Message:
dis(): Simplified stack emulation a bit.
Index: pickletools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickletools.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** pickletools.py 29 Jan 2003 20:12:21 -0000 1.22
--- pickletools.py 30 Jan 2003 15:02:12 -0000 1.23
***************
*** 1899,1906 ****
maxproto = max(maxproto, opcode.proto)
-
- # See whether a MARK should be popped.
before = opcode.stack_before # don't mutate
after = opcode.stack_after # don't mutate
markmsg = None
if markobject in before or (opcode.name == "POP" and
--- 1899,1907 ----
maxproto = max(maxproto, opcode.proto)
before = opcode.stack_before # don't mutate
after = opcode.stack_after # don't mutate
+ numtopop = len(before)
+
+ # See whether a MARK should be popped.
markmsg = None
if markobject in before or (opcode.name == "POP" and
***************
*** 1908,1911 ****
--- 1909,1915 ----
stack[-1] is markobject):
assert markobject not in after
+ if __debug__:
+ if markobject in before:
+ assert before[-1] is stackslice
if markstack:
markpos = markstack.pop()
***************
*** 1918,1929 ****
stack.pop()
stack.pop()
! # Remove markobject stuff from stack_before.
try:
! i = before.index(markobject)
! before = before[:i]
except ValueError:
assert opcode.name == "POP"
! assert len(before) == 1
! before = [] # stop code later from popping again
else:
errormsg = markmsg = "no MARK exists on stack"
--- 1922,1931 ----
stack.pop()
stack.pop()
! # Stop later code from popping too much.
try:
! numtopop = before.index(markobject)
except ValueError:
assert opcode.name == "POP"
! numtopop = 0
else:
errormsg = markmsg = "no MARK exists on stack"
***************
*** 1931,1934 ****
--- 1933,1937 ----
# Check for correct memo usage.
if opcode.name in ("PUT", "BINPUT", "LONG_BINPUT"):
+ assert arg is not None
if arg in memo:
errormsg = "memo key %r already defined" % arg
***************
*** 1962,1973 ****
# Emulate the stack effects.
! n = len(before)
! if len(stack) < n:
! raise ValueError("tried to pop %d items from stack with "
! "only %d items" % (n, len(stack)))
! if n:
! del stack[-n:]
if markobject in after:
! assert markobject not in opcode.stack_before
markstack.append(pos)
--- 1965,1975 ----
# Emulate the stack effects.
! if len(stack) < numtopop:
! raise ValueError("tries to pop %d items from stack with "
! "only %d items" % (numtopop, len(stack)))
! if numtopop:
! del stack[-numtopop:]
if markobject in after:
! assert markobject not in before
markstack.append(pos)
- Previous message: [Python-checkins] python/nondist/sandbox/doctools README,1.2,NONE htmldoc.py,1.2,NONE inspect.py,1.1,NONE onlinehelp.py,1.4,NONE textdoc.py,1.1,NONE
- Next message: [Python-checkins] python/dist/src/Python modsupport.c,2.63,2.64
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]