fixed strings in confgiparser

master
idziubenko 3 years ago
parent 510ea45ad6
commit e2f0ad4648

@ -760,7 +760,7 @@ class RawConfigParser(MutableMapping):
"""
elements_added = set()
for section, keys in dictionary.items():
section = unicode(section)
section = str(section)
try:
self.add_section(section)
except (DuplicateSectionError, ValueError):
@ -768,9 +768,9 @@ class RawConfigParser(MutableMapping):
raise
elements_added.add(section)
for key, value in keys.items():
key = self.optionxform(unicode(key))
key = self.optionxform(str(key))
if value is not None:
value = unicode(value)
value = str(value)
if self._strict and (section, key) in elements_added:
raise DuplicateOptionError(section, key, source)
elements_added.add((section, key))
@ -1011,7 +1011,7 @@ class RawConfigParser(MutableMapping):
value = self._interpolation.before_write(self, section_name, key,
value)
if value is not None or not self._allow_no_value:
value = delimiter + unicode(value).replace(u'\n', u'\n\t')
value = delimiter + str(value).replace(u'\n', u'\n\t')
else:
value = u""
fp.write(u"{0}{1}\n".format(key, value))
@ -1230,7 +1230,7 @@ class RawConfigParser(MutableMapping):
if vars:
for key, value in vars.items():
if value is not None:
value = unicode(value)
value = str(value)
vardict[self.optionxform(key)] = value
return _ChainMap(vardict, sectiondict, self._defaults)
@ -1276,8 +1276,8 @@ class RawConfigParser(MutableMapping):
if not self._allow_no_value or value:
if not isinstance(value, basestring):
raise TypeError(u"option values must be strings")
return (unicode(section), unicode(option), (value if value is None
else unicode(value)))
return (str(section), str(option), (value if value is None
else str(value)))
class ConfigParser(RawConfigParser):

Loading…
Cancel
Save