[Python-checkins] python/dist/src/Lib pickletools.py,1.29,1.30
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Tue Feb 15 17:22:37 CET 2005
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12464/Lib
Modified Files:
pickletools.py
Log Message:
An instance of class PicklingError was used here simply as an example of
_some_ user-defined class instance. That it was also an exception isn't
interesting, but does interfere with Michael Hudson's new-style exception
patch. This just changes the doctest example, to use an instance of a
non-exception class.
Index: pickletools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickletools.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- pickletools.py 7 Dec 2004 08:26:10 -0000 1.29
+++ pickletools.py 15 Feb 2005 16:22:34 -0000 1.30
@@ -1996,6 +1996,11 @@
if stack:
raise ValueError("stack not empty after STOP: %r" % stack)
+# For use in the doctest, simply as an example of a class to pickle.
+class _Example:
+ def __init__(self, value):
+ self.value = value
+
_dis_test = r"""
>>> import pickle
>>> x = [1, 2, (3, 4), {'abc': u"def"}]
@@ -2060,27 +2065,27 @@
18: . STOP
highest protocol among opcodes = 0
->>> x = [pickle.PicklingError()] * 2
+>>> from pickletools import _Example
+>>> x = [_Example(42)] * 2
>>> dis(pickle.dumps(x, 0))
0: ( MARK
1: l LIST (MARK at 0)
2: p PUT 0
5: ( MARK
- 6: i INST 'pickle PicklingError' (MARK at 5)
+ 6: i INST 'pickletools _Example' (MARK at 5)
28: p PUT 1
31: ( MARK
32: d DICT (MARK at 31)
33: p PUT 2
- 36: S STRING 'args'
- 44: p PUT 3
- 47: ( MARK
- 48: t TUPLE (MARK at 47)
- 49: s SETITEM
- 50: b BUILD
- 51: a APPEND
- 52: g GET 1
- 55: a APPEND
- 56: . STOP
+ 36: S STRING 'value'
+ 45: p PUT 3
+ 48: I INT 42
+ 52: s SETITEM
+ 53: b BUILD
+ 54: a APPEND
+ 55: g GET 1
+ 58: a APPEND
+ 59: . STOP
highest protocol among opcodes = 0
>>> dis(pickle.dumps(x, 1))
@@ -2088,20 +2093,20 @@
1: q BINPUT 0
3: ( MARK
4: ( MARK
- 5: c GLOBAL 'pickle PicklingError'
+ 5: c GLOBAL 'pickletools _Example'
27: q BINPUT 1
29: o OBJ (MARK at 4)
30: q BINPUT 2
32: } EMPTY_DICT
33: q BINPUT 3
- 35: U SHORT_BINSTRING 'args'
- 41: q BINPUT 4
- 43: ) EMPTY_TUPLE
- 44: s SETITEM
- 45: b BUILD
- 46: h BINGET 2
- 48: e APPENDS (MARK at 3)
- 49: . STOP
+ 35: U SHORT_BINSTRING 'value'
+ 42: q BINPUT 4
+ 44: K BININT1 42
+ 46: s SETITEM
+ 47: b BUILD
+ 48: h BINGET 2
+ 50: e APPENDS (MARK at 3)
+ 51: . STOP
highest protocol among opcodes = 1
Try "the canonical" recursive-object test.
More information about the Python-checkins
mailing list