Pickled text file causing ValueError (dos/unix issue) | Bytes (2024)

Home Posts Topics Members FAQ

Aki Niimura

Hello everyone,

I started to use pickle to store the latest user settings for the tool
I wrote. It writes out a pickled text file when it terminates and it
restores the settings when it starts.

It worked very nicely.

However, I got a ValueError when I started the tool from Unix when I
previously used the tool from Windows.

File "/usr/local/lib/python2.3/pickle.py", line 980, in load_string
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle

If I do 'dos2unix <my.cfg> <my.cfg>' to convert the file, then
everything
becomes fine.

I found in the Python release note saying ...
"pickle: Now raises ValueError when an invalid pickle that contains a
non-string repr where a string repr was expected. This behavior matches
cPickle."

I guess DOS text format is creating this problem.
My question is "Is there any elegant way to deal with this?".

I certainly can catch ValueError and run 'dos2unix' explicitly.
But I don't like such crude solution.
Any suggestions would be highly appreciated.

Best regards,
Aki Niimura

Jul 18 '05

Subscribe Reply

12 Pickled text file causing ValueError (dos/unix issue) | Bytes (1) 4222 Pickled text file causing ValueError (dos/unix issue) | Bytes (2)

  • <
  • 1
  • 2

Cameron Laird

In article <ma************ *************** ***********@pyt hon.org>,
Tim Peters <ti********@gma il.com> wrote:

Jul 18 '05 #11

Skip Montanaro

Tim> "Plays well with others" was a strong motivator for Python's
Tim> design, and that often means playing by others' rules. --

My vote for QOTW... Is it too late to slip it into the Zen of Python?

Skip

Jul 18 '05 #12

Nick Coghlan

Skip Montanaro wrote:

Tim> "Plays well with others" was a strong motivator for Python's
Tim> design, and that often means playing by others' rules. --

My vote for QOTW... Is it too late to slip it into the Zen of Python?

It would certainly fit, and the existing koans don't really cover the concept.

Its addition also seems fitting in light of the current PEP 246 discussion which
is *all* about playing well with others :)

Cheers,
Nick.

--
Nick Coghlan | nc******@email. com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net

Jul 18 '05 #13

  • <
  • 1
  • 2

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

Similar topics

1 2746

"readline()" omitted '\r' in win32 for dos format text file

by: Newgene |last post by:

Hi, group, I have python2.3 installed on win2k. I noticed that when I open a dos format text file (eol is '\r\n'), readline() always returns a line ending with '\n' only, not '\r\n'. While I read the same file on unix, it returns a line ending with '\r\n' correctly. This makes me difficult to determine the format of a text file, dos or unix....

Python

27 4912

[Q] Text vs Binary Files

by: Eric |last post by:

Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there any solid reasons to prefer text files over binary files files?

.NET Framework

11 3609

by: BoonHead, The Lost Philosopher |last post by:

I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own rules when it comes to file paths. A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle...

.NET Framework

8 3408

Dos vs Unix style text files

by: Dave Moore |last post by:

I realize this is a somewhat platform specific question, but I think it is still of general enough interest to ask it here ... if I am wrong I guess I will find out 8*). As we all know, DOS uses two characters (carriage-return and line-feed), to signal the end of a line, while UNIX uses only one (line-feed). When using getline in C++, one...

C / C++

2 1818

table linked to text file producing extra rows

by: Larry Rekow |last post by:

A friend's unix application produces various reports daily as flat text files. I link these files as tables in an Access (2000) database. After linking, all of these reports begin with a blank row; no problem. But the latest report I've asked, once linked, creates not only a blank row at the beginning, but a blank row after every row...

Microsoft Access / VBA

8 9719

VB.Net file access problem with UNC

by: Sarah |last post by:

I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC...

Visual Basic .NET

10 5939

Text mode fseek/ftell

by: Kenneth Brody |last post by:

I recently ran into an "issue" related to text files and ftell/fseek, and I'd like to know if it's a bug, or simply an annoying, but still conforming, implementation. The platform is Windows, where text files use CF+LF (0x0d, 0x0a) to mark end-of-line. The file in question, however, was in Unix format, with only LF (0x0a) at the end of...

C / C++

2 1175

is there a module to work with pickled objects storage in database?

by: krishnakant Mane |last post by:

hello all, I am trying a very complex kind of a task in a project. I have a knowledge management system where I need to store a lot of objects (pickled). I have to store mostly lists and dictionaries into a rdbms. mostly I will be using mysql. I want to know if there is any module that can help me store a pickled object inside a blob field...

Python

7807

What is ONU?

by: marktang |last post by:

ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...

General

7730

Changing the language in Windows 10

by: Hystou |last post by:

Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...

Windows Server

8058

Problem With Comparison Operator <=> in G++

by: Oralloy |last post by:

Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...

C / C++

1 7820

The easy way to turn off automatic updates for Windows 10/11

by: Hystou |last post by:

Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...

Windows Server

8100

Discussion: How does Zigbee compare with other wireless protocols in smart home applications?

by: tracyyun |last post by:

Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...

General

5301

Couldn’t get equations in html when convert word .docx file to html file in C#.

by: conductexam |last post by:

I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...

C# / C Sharp

3753

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 2249

transfer the data from one system to another through ip address

by: 6302768590 |last post by:

Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

C# / C Sharp

1061

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

by: bsmnconsultancy |last post by:

In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

General

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

To disable or enable advertisem*nts and analytics tracking please visit the page.

Pickled text file causing ValueError (dos/unix issue) | Bytes (2024)
Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6591

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.