[ python-Bugs-1157576 ] pickle errors
SourceForge.net
noreply at sourceforge.net
Sun Mar 6 06:57:41 CET 2005
Bugs item #1157576, was opened at 2005-03-05 23:31
Message generated for change (Comment added) made by laxori666
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1157576&group_id=5470
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Laxori666 (laxori666)
Assigned to: Nobody/Anonymous (nobody)
Summary: pickle errors
Initial Comment:
pickle is giving me an error while I'm trying to
serialize a dictionary.
Here is the dictionary:
>>> a
{' ': (0, 2), '(': (858, 10), ',': (480, 9), '0': (327,
9), '4': (1393, 11), '8': (1396, 11), '@': (3496, 13),
'D': (212, 8), 'H': (1749, 12), 'L': (328, 9), 'P':
(344, 9), 'T': (215, 8), 'X': (4041, 12), '\': (859,
10), 'd': (16, 5), 'h': (61, 6), 'l': (17, 5), 'p':
(19, 6), 't': (5, 4), 'x': (83, 7), '#': (2632, 12),
"'": (330, 9), '+': (2633, 12), '/': (160, 8), '3':
(697, 10), '7': (2796, 12), '?': (2634, 12), 'C': (175,
8), 'G': (659, 10), 'K': (5571, 13), 'O': (173, 8),
'S': (241, 8), 'W': (662, 10), '[': (144, 9), 'c': (8,
5), 'g': (127, 7), 'k': (161, 8), 'o': (9, 4), 's':
(22, 5), 'w': (104, 7), '\n': (14, 5), '"': (162, 8),
'.': (26, 6), '2': (219, 9), '6': (1399, 11), ':':
(253, 8), 'B': (108, 8), 'F': (426, 9), 'J': (3497,
13), 'N': (146, 9), 'R': (326, 9), 'V': (875, 11), 'Z':
(8080, 13), 'b': (105, 7), 'f': (42, 6), '\xe9': (5570,
13), 'j': (8081, 13), 'n': (27, 5), 'r': (23, 5), 'v':
(37, 7), 'z': (663, 10), '~': (2635, 12), '\t': (2021,
11), '!': (1397, 11), '%': (2784, 12), ')': (1008, 10),
'-': (55, 7), '1': (1009, 10), '5': (4046, 12), '9':
(2797, 12), '=': (15, 5), 'A': (428, 9), 'E': (147, 9),
'I': (481, 9), 'M': (427, 9), 'Q': (436, 10), 'U':
(345, 9), 'Y': (2022, 11), ']': (145, 9), 'a': (29, 5),
'e': (12, 4), 'i': (28, 5), 'm': (62, 6), 'q': (4047,
12), 'u': (12, 5), 'y': (121, 7)}
Here is the series of commands I issue, resulting in an
error:
>>> afile = open("afile", "wb")
>>> p=pickle.Pickler(afile)
>>> p.save(a)
>>> afile.close()
>>> afile = open("afile", "rb")
>>> p=pickle.Unpickler(afile)
>>> a2 = p.load()
Traceback (most recent call last):
File "<pyshell#69>", line 1, in ?
a2 = p.load()
File "H:\Python24\lib\pickle.py", line 872, in load
dispatch[key](self)
File "H:\Python24\lib\pickle.py", line 894, in load_eof
raise EOFError
EOFError
Am I doing something wrong or is this pickle's fault?
----------------------------------------------------------------------
>Comment By: Laxori666 (laxori666)
Date: 2005-03-06 00:57
Message:
Logged In: YES
user_id=1209371
Oh, silly me. I should've noticed something was strange when
cPickle didn't have a save method. I don't know, I must've
stumbled into it and thought it was the right one. Thanks
for your help.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2005-03-06 00:04
Message:
Logged In: YES
user_id=31435
I'm confused by why you're using the Pickler.save() method.
That's an internal method, not even documented. If you use
the documented Pickler.dump() method instead, this should
work fine with pickle.py.
There's no guarantee about the size or content of pickle
strings, BTW, and cPickle does play tricks not available to
pickle.py.
----------------------------------------------------------------------
Comment By: Laxori666 (laxori666)
Date: 2005-03-05 23:34
Message:
Logged In: YES
user_id=1209371
NOTE: doing this using cPickle works without a problem. Also
note that the file is 2KB smaller under cPickle. If they are
supposed to be using the same stream, I think that is a
problem (the same protocol argument was used for both)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1157576&group_id=5470
More information about the Python-bugs-list
mailing list