Re: pickle problem on 2.3.4 pythonCE (for wxPython)

"Luke Dunstan" <[email protected]>
Newsgroups gmane.comp.python.windows-ce
Message-ID <[email protected]>
>From: "Matt S." <[email protected]>
>To: "Luke Dunstan" <[email protected]>
>Subject: Re: [PythonCE] pickle problem on 2.3.4 pythonCE (for wxPython)
>Date: Sat, 27 May 2006 20:25:46 -0700
>
>Python 2.3.4 is the only Python interpreter I've seen wxPython
>compiled with for CE.  Did it work for you on 2.3.4 or 2.4.3?  If it
>did work on 2.4.3 for you do you have wxPython running as well?
>Thanks for the follow up.
>
>Matt

Yes, 2.4.3. Sorry, I don't have wxPython running as well. You might want to 
try 2.3.5 but I haven't tried it so there is no guarantee that it will fix 
the problem.

Luke

>
>On 5/27/06, Luke Dunstan <[email protected]> wrote:
>>Hi,
>>
>>Your test program works for me on PythonCE 2.4.3.
>>
>>Luke
>>
>>----- Original Message -----
>>From: "Matt S." <[email protected]>
>>To: <[email protected]>
>>Sent: Saturday, May 27, 2006 3:47 AM
>>Subject: [PythonCE] pickle problem on 2.3.4 pythonCE (for wxPython)
>>
>>
>> > Hi,
>> >
>> > I'm trying to make a data collection UI for Windows CE using the
>> > wxPyCE distribution (which uses Python 2.3.4)  found at,
>> >
>> > http://www.traybor.com/PythonCE/
>> >
>> > It's gone well so far but I'm running into a serious data pickling
>> > problem.  Ideally I would like to pickle a class instance.
>> >
>> > Saving and loading the pickled class works fine on my PC (Python 2.4x),
>> >
>> > *pickleDump.py*
>> > f = open('pickle_file.pyp', 'r')
>> > pickle.dump(my_class_instance, f)
>> >
>> > *pickleLoad.py*
>> > f = open('saved_pickle.pyp', 'r')
>> > my_pickled_class_instance = pickle.load(f)
>> >
>> > In my UI module the pickling are methods in a class.  Also, "my_class"
>> > is actually, "another_module.top_level_class.data," wherein ".data" is
>> > a dictionary with keys that are person names and values that are the
>> > corresponding person instance.
>> >
>> > Realizing that I'm probably breaking the pickling rules with pickling
>> > my data class, I changed "my_class" in *pickleDump.py* to a simple
>> > dictionary...  and it still failed on CE.  Fortunately, simplifying my
>> > data to a simple list does pickle.  So, in the worst case I can
>> > convert my data into lists (not pretty so if you have a better
>> > workaround idea I'd really appreciate it).
>> >
>> > Here's the traceback from my attempt to load the pickled dictionary,
>> >
>> > Traceback (most recent call last):
>> >  File "\Program Files\python\dev\pickleLoad.py", line 10, in ?
>> >    var = pickle.load(f)
>> >  File "binaries\lib\pickle.py", line 1390, in load
>> >  File "binaries\lib\pickle.py", line 872, in load
>> >  File "binaries\lib\pickle.py", line 985, in load_string
>> > LookupError: no codec search functions registered: can't find encoding
>> >
>> > Here are my test modules,
>> >
>> > *pickleDump.py*
>> >
>> > import pickle, traceback, sys
>> >
>> > f = open('test.txt','w')
>> > error = open('dump_error.txt','w')
>> > sys.stderr = error
>> > log = open('dump_out.txt','w')
>> > sys.stdout = log
>> >
>> > #var = [n for n in range(10)]
>> > var = {'parm1':1, 'parm2':'2a'}
>> >
>> > try:
>> >
>> >    pickle.dump(var,f)
>> >    print 'Pickled dumped OK in,', __file__
>> > except:
>> >    traceback.print_exc()
>> >    print 'Pickle dump failed! in', __file__
>> >
>> > f.close()
>> >
>> >
>> > *pickleLoad.py*
>> >
>> > import pickle, sys, traceback
>> >
>> > e = open('load_error.txt','w')
>> > sys.stderr = e
>> > s = open('load_out.txt','w')
>> > sys.stdout = s
>> >
>> > try:
>> >    f = open('test.txt','r')
>> >    var = pickle.load(f)
>> >    print 'Pickle loaded OK in,', __file__
>> >    print var
>> > except:
>> >
>> >    traceback.print_exc()
>> >    print 'Pickle not loaded in,', __file__
>> >
>> > Many thanks for your help,
>> > Matt
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.