From df18f7b042e7a5a6dc0d61310a176397382f5ac0 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Tue, 6 Dec 2016 11:01:17 +0100 Subject: [PATCH] Switch configparser to raw mode --- src/configparser.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/configparser.py b/src/configparser.py index 2deb3d0f..64b30b25 100644 --- a/src/configparser.py +++ b/src/configparser.py @@ -1,7 +1,15 @@ -from ConfigParser import SafeConfigParser +from ConfigParser import SafeConfigParser, ConfigParser class BMConfigParser(SafeConfigParser): def set(self, section, option, value=None): - if value is not None: - value = value.replace('%', '%%') - return SafeConfigParser.set(self, section, option, value) + if self._optcre is self.OPTCRE or value: + if not isinstance(value, basestring): + raise TypeError("option values must be strings") + return ConfigParser.set(self, section, option, value) + + def get(self, section, option, raw=False, vars=None): + return ConfigParser.get(self, section, option, True, vars) + + def items(self, section, raw=False, vars=None): + return ConfigParser.items(self, section, True, vars) +