Re: SafeConfigParser can set unsafe values



I agree, but that was a trivial example to demonstrate the problem.
Writing the file out to disk writes it exactly as set(), causing a get()
to fail just the same later.

No... The above statement is not true.

The following code:

[code]
from ConfigParser import *
import sys

cp = SafeConfigParser()
cp.add_section("sect")
cp.set("sect","opt","hello%world")

cp.write(sys.stdout)
[/code]

Produces this output:
[sect]
opt = hello%world

The write method never calls get. However, when you read the file that
was output by the above code using .get(...) will raise an error. You
can avoid that error by setting the optional 'raw' parameter to True.

.



Relevant Pages

  • Re: Saving Custom Data
    ... additional overhead of using class objects to represent each record? ... You should choose structures or classes based on how you are going to use them in your program, not on the need of writing to disk. ... For example, most leave the line that opens the file (the line most likely to fail) before try, outside of the try block? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SafeConfigParser can set unsafe values
    ... Matimus wrote: ... Writing the file out to disk writes it exactly as set, causing a getto fail just the same later. ...
    (comp.lang.python)
  • Re: File Merge
    ... You cannot know what happened until it actually happens -- so the only way to know that you have reached end-of-input is to try to read something and get a failure. ... might fail: for example, input from a disk could fail in the event of a head crash, or input from a keyboard could fail if you spilled Coke Classic into the mechanism and shorted it out with caramelized sugar. ... Most of C's input functions report a kind of "generalized failure" no matter what the cause -- and the *only* reason feof() exists is to let you figure out that cause. ...
    (comp.lang.c)
  • Temporary lock-up under heavy write, MegaRAID RAID-5
    ... LSI Logic MegaRAID 320-1, 64MB cache ... when writing very large files. ... disk write access, actually). ... The RAID controller is currently set to "write-through". ...
    (Debian-User)
  • Re: Beth HaWaadh Permits Eating of Kitniyoth by all Jews in Israel During Pesah
    ... pasuq, ask me why I do not think writing (not even pronouncing, mind ... says this pasuq is a negative commandment. ... Rambam himself gives an example of what the words mean, ... I never wondered why you fail to address me as a talmid chacham. ...
    (soc.culture.jewish.moderated)