summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-05-07 23:57:08 (GMT)
committerGuido van Rossum <guido@python.org>2007-05-07 23:57:08 (GMT)
commit617dbc4d643749804057f8dc7c52df702e40fe7a (patch)
tree6d8536fa856655cbcfa26404bbdbc495f97f7397 /Lib
parent805365ee39298f93e433e19ae0dd87c6f782145b (diff)
downloadcpython-617dbc4d643749804057f8dc7c52df702e40fe7a.zip
cpython-617dbc4d643749804057f8dc7c52df702e40fe7a.tar.gz
cpython-617dbc4d643749804057f8dc7c52df702e40fe7a.tar.bz2
Checkpoint. A b it closer to working pickles and pickletools.
Added 'Y' getargs opcode which requires a bytes object.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pickletools.py3
-rw-r--r--Lib/test/test_exceptions.py9
2 files changed, 8 insertions, 4 deletions
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index b4b2840..c050fc5 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -1760,11 +1760,12 @@ def assure_pickle_consistency(verbose=False):
print("skipping %r: it doesn't look like an opcode name" % name)
continue
picklecode = getattr(pickle, name)
- if not isinstance(picklecode, str) or len(picklecode) != 1:
+ if not isinstance(picklecode, bytes) or len(picklecode) != 1:
if verbose:
print(("skipping %r: value %r doesn't look like a pickle "
"code" % (name, picklecode)))
continue
+ picklecode = picklecode.decode("latin-1")
if picklecode in copy:
if verbose:
print("checking name %r w/ code %r for consistency" % (
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index aa9b66d..934d50e 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -251,12 +251,12 @@ class ExceptionTests(unittest.TestCase):
'print_file_and_line' : None, 'msg' : 'msgStr',
'filename' : None, 'lineno' : None, 'offset' : None}),
(UnicodeError, (), {'message' : '', 'args' : (),}),
- (UnicodeEncodeError, ('ascii', 'a', 0, 1, 'ordinal not in range'),
+ (UnicodeEncodeError, (str8('ascii'), 'a', 0, 1, str8('ordinal not in range')),
{'message' : '', 'args' : ('ascii', 'a', 0, 1,
'ordinal not in range'),
'encoding' : 'ascii', 'object' : 'a',
'start' : 0, 'reason' : 'ordinal not in range'}),
- (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'),
+ (UnicodeDecodeError, (str8('ascii'), b'\xff', 0, 1, str8('ordinal not in range')),
{'message' : '', 'args' : ('ascii', '\xff', 0, 1,
'ordinal not in range'),
'encoding' : 'ascii', 'object' : '\xff',
@@ -278,6 +278,7 @@ class ExceptionTests(unittest.TestCase):
for exc, args, expected in exceptionList:
try:
+ print("exc=%r, args=%r" % (exc, args))
raise exc(*args)
except BaseException as e:
if type(e) is not exc:
@@ -297,7 +298,9 @@ class ExceptionTests(unittest.TestCase):
if p is None:
continue # cPickle not found -- skip it
for protocol in range(p.HIGHEST_PROTOCOL + 1):
- new = p.loads(p.dumps(e, protocol))
+ ##print("p=%s, protocol=%s, e=%r" % (p.__name__, protocol, e))
+ s = p.dumps(e, protocol)
+ new = p.loads(s)
for checkArgName in expected:
got = repr(getattr(new, checkArgName))
want = repr(expected[checkArgName])