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
12 4277
In article <ma************ *************** ***********@pyt hon.org>,
Tim Peters <ti********@gma il.com> 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?
Skip
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
Is this a bug or intended behavior? If not a bug, then how to
determine the format of a text...
|
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?
|
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 paths in the following manner:
|
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 can only specify a single character as the terminator
(default is '\n'), so if you read a line of...
|
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 with data.
| |
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 access to the file is included below and is put in the tick event of
a form timer control running every...
|
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 each line.
First, does the above situation already invoke "implementation defined"
or "undefined"...
|
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 instead of
a file. I know that pickle.dump() can store an object into a file but
I can't find a...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |