473,287 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

KeyError in pickle

Hi,

I am using pickle/unpickle to let my program save its documents to
disk. While this it worked stable for a long time, one of my users now
complained, that he had a file which can't be loaded.

The traceback is:

File "pickle.pyo", line 1374, in loads
File "pickle.pyo", line 858, in load
KeyError: 'A'
Does anybody know this problem. How this can happen and how can I
avoid it?

Thanks,
Christof
Jun 27 '08 #1
2 7815
christof wrote:
I am using pickle/unpickle to let my program save its documents to
disk. While this it worked stable for a long time, one of my users now
complained, that he had a file which can't be loaded.

The traceback is:

File "pickle.pyo", line 1374, in loads
File "pickle.pyo", line 858, in load
KeyError: 'A'
Does anybody know this problem. How this can happen and how can I
avoid it?
Is this reproducible? How? If not I would guess that the file is corrupted.

Peter
Jun 27 '08 #2
On 23 Mai, 10:48, Peter Otten <__pete...@web.dewrote:
christof wrote:
I am using pickle/unpickle to let my program save its documents to
disk. While this it worked stable for a long time, one of my users now
complained, that he had a file which can't be loaded.
The traceback is:
File "pickle.pyo", line 1374, in loads
File "pickle.pyo", line 858, in load
KeyError: 'A'
Does anybody know this problem. How this can happen and how can I
avoid it?

Is this reproducible? How? If not I would guess that the file is corrupted.

Peter
I found the problem: the user did a text export and gave the exported
file the wrong extension. So: the file was not valid python pickle. I
should add a type signature to fhe file format to avoid this.

Thanks anyway,
Christof
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Hohn | last post by:
Hi, under python 2.2, the pickle/unpickle sequence incorrectly restores a larger data structure I have. Under Python 2.3, these structures now give an explicit exception from...
3
by: Rune Strand | last post by:
I'm experiencing strange errors both with pickle and cPickle in the below code: import cPickle as pickle #import pickle from string import ascii_uppercase from string import ascii_lowercase...
0
by: Mike P. | last post by:
Hi all, I'm working on a simulation (can be considered a game) in Python where I want to be able to dump the simulation state to a file and be able to load it up later. I have used the standard...
6
by: Jim Lewis | last post by:
Pickling an instance of a class, gives "can't pickle instancemethod objects". What does this mean? How do I find the class method creating the problem?
10
by: crystalattice | last post by:
I'm creating an RPG for experience and practice. I've finished a character creation module and I'm trying to figure out how to get the file I/O to work. I've read through the python newsgroup...
5
by: Chris | last post by:
Why can pickle serialize references to functions, but not methods? Pickling a function serializes the function name, but pickling a staticmethod, classmethod, or instancemethod generates an...
3
by: fizilla | last post by:
Hello all! I have the following weird problem and since I am new to Python I somehow cannot figure out an elegant solution. The problem reduces to the following question: How to pickle a...
2
by: Michele Simionato | last post by:
Can somebody explain what's happening with the following script? $ echo example.py import pickle class Example(object): def __init__(self, obj, registry): self._obj = obj self._registry =...
1
by: IceMan85 | last post by:
Hi to all, I have spent the whole morning trying, with no success to pickle an object that I have created. The error that I get is : Can't pickle 'SRE_Match' object: <_sre.SRE_Match object at...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.