The SafeConfigParser class incorrectly detects lone percent signs, for example, it doesn't accept "100%%" as a valid value. The cause of this is the "_badpercent_re" regular expression: - The first alternative "%[^%]" fails with the string "%%_", because it matches "%_". - The second alternative "%$" fails with the string "%%", because it matches "%". --- from ConfigParser import * SafeConfigParser().set('DEFAULT', 'test', '100%%')
Shouldn't the "replace('%%', '')" take place before "_interpvar_re.sub"? For example, the value "%%(test)s" should be accepted as valid but it isn't because "_interpvar_re" has already changed it to "%".