SafeConfigParser can set unsafe values

Matimus mccredie at
Wed Jul 11 07:20:52 CEST 2007

> 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:

from ConfigParser import *
import sys

cp = SafeConfigParser()


Produces this output:
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.

More information about the Python-list mailing list