Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ValueError: insecure pickle string

Reply
Thread Tools

ValueError: insecure pickle string

 
 
pradeepbpin
Guest
Posts: n/a
 
      03-28-2011
I am encountering 'Value Error: insecure string pickle' when trying to
execute the script on Ubuntu. The same script and the pickled file
works without any problem in Windows. For working in Ubuntu I just
copied both the script file and pickled file from Windows.


How can I get out of this error? Rather, I would like to have common
script and pickled file that can work platform independently.
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      03-28-2011
pradeepbpin wrote:

> I am encountering 'Value Error: insecure string pickle' when trying to
> execute the script on Ubuntu. The same script and the pickled file
> works without any problem in Windows. For working in Ubuntu I just
> copied both the script file and pickled file from Windows.
>
>
> How can I get out of this error? Rather, I would like to have common
> script and pickled file that can work platform independently.


Try opening the file in universal newline mode:

f = open("my.pickle", "U")
print pickle.load(f)

This will convert Windows "\r\n" line endings to "\n".

For new data: an alternative is to open the file in binary mode for both
reading and writing on all platforms. This will also allow you to switch to
the more efficient binary pickle protocols.
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      03-28-2011
On Mon, 28 Mar 2011 08:53:35 -0700, pradeepbpin wrote:

> I am encountering 'Value Error: insecure string pickle' when trying to
> execute the script on Ubuntu. The same script and the pickled file works
> without any problem in Windows. For working in Ubuntu I just copied both
> the script file and pickled file from Windows.


What version of Python are you using on Ubuntu? Is it the same version of
Python on Windows?

Please show the full error traceback and the string that causes the error.




--
Steven
 
Reply With Quote
 
pradeepbpin
Guest
Posts: n/a
 
      03-28-2011


> For new data: an alternative is to open the file in binary mode for both
> reading and writing on all platforms. This will also allow you to switch to
> the more efficient binary pickle protocols.


Writing and reading the pickled file in binary mode seems to be
working. Thank you.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pickle error: can't pickle instancemethod objects Michele Simionato Python 2 05-23-2008 08:29 AM
ValueError: insecure string pickle ? robert Python 2 09-11-2007 06:50 PM
a pickle's pickle temposs@gmail.com Python 4 08-02-2005 07:20 PM
Secure page with Insecure Elements =?Utf-8?B?VmluY2UgTWVsZQ==?= ASP .Net 3 07-06-2004 04:12 PM
Help untaining the command. Insecure dependency in `` ... setuid danpres2k Perl 0 08-13-2003 03:21 PM



Advertisments