Mailing List Archive

unpickling an NT object in Solaris?
Hi,

I created an object running python on NT and pickled it. I have no problem
unpickling on NT, but when I ftp'd the file over to Solaris, I get an
ImportError exception ("No module named __main__^M") when I try to
unpickle it.

Is this a 1.5.2 (on NT) vs. 1.5.1 (on Solaris) problem, or am I mistaken
in expecting the pickled objects to work cross-platform?

Thanks!
unpickling an NT object in Solaris? [ In reply to ]
On Tue, 20 Apr 1999, Bill Dozier wrote:
> ImportError exception ("No module named __main__^M") when I try to
^^
It seems you ftp'd file in text mode. Try binary ftp.

Oleg.
----
Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/
Programmers don't die, they just GOSUB without RETURN.
unpickling an NT object in Solaris? [ In reply to ]
On Tue, 20 Apr 1999 10:57:49 -0400, dozier@bellatlantic.net (Bill Dozier) wrote:

>Hi,
>
>I created an object running python on NT and pickled it. I have no problem
>unpickling on NT, but when I ftp'd the file over to Solaris, I get an
>ImportError exception ("No module named __main__^M") when I try to
>unpickle it.
>

Pickling uses a text format which should be platform independent.

My guess: Did you transfer via FTP in text mode? In that case, line
endings get converted. "__main__^M" seems to point at this.

Stefan
unpickling an NT object in Solaris? [ In reply to ]
Problem solved. It seems that the cPickle module is not sufficiently
cross-platform.

The text mode of pickling is not cross-platform and seems to expect UNIX
linefeeds. :P

If I use the binary mode, everything's OK.


In article
<dozier-2004991057490001@client-151-200-124-68.bellatlantic.net>,
dozier@bellatlantic.net (Bill Dozier) wrote:

>I created an object running python on NT and pickled it. I have no problem
>unpickling on NT, but when I ftp'd the file over to Solaris, I get an
>ImportError exception ("No module named __main__^M") when I try to
>unpickle it.
>
unpickling an NT object in Solaris? [ In reply to ]
dozier@bellatlantic.net (Bill Dozier) writes:

> Problem solved. It seems that the cPickle module is not sufficiently
> cross-platform.
>
> The text mode of pickling is not cross-platform and seems to expect UNIX
> linefeeds. :P

Nonsense. However you must open the file you're pickling to in binary
mode: open(filename,'wb').

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
unpickling an NT object in Solaris? [ In reply to ]
In article <5lzp42smtd.fsf@eric.cnri.reston.va.us>, Guido van Rossum
<guido@eric.cnri.reston.va.us> wrote:

>dozier@bellatlantic.net (Bill Dozier) writes:
>>
>> The text mode of pickling is not cross-platform and seems to expect UNIX
>> linefeeds. :P
>
>Nonsense. However you must open the file you're pickling to in binary
>mode: open(filename,'wb').
>

Unfortunately, this detail is not found in the documentation. It certainly
does not seem obvious that one should write a text file in binary mode.
unpickling an NT object in Solaris? [ In reply to ]
[Bill Dozier]
> The text mode of pickling is not cross-platform and seems to
> expect UNIX linefeeds. :P

[Guido]
> Nonsense. However you must open the file you're pickling to in binary
> mode: open(filename,'wb').

[Bill]
> Unfortunately, this detail is not found in the documentation. It
> certainly does not seem obvious that one should write a text file
> in binary mode.

It does if you've tried to port any other kind of text file from Windows to
Unix, whether via Python or C -- there's nothing unique to pickle in this!
Windows text files aren't properly read by Unix libc file routines, and
that's all there is to it.

text-files-aren't-portable-period-ly y'rs - tim