<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I should like to report a bug on the module 'configparser.py' <div>Python version: 3.4.0 run on Mac os 10.6.8<div><br></div><div><div> ### Error in 'str' name and 'str' function</div><div> def _write_section(self, fp, section_name, section_items, delimiter):</div><div> """Write a single section to the specified `fp'."""</div><div> #fp.write("[{}]\n".format(section_name))</div><div> <font class="Apple-style-span" color="#fe2b17">str</font> = "[{}]\n".format(section_name)</div><div> fp.write(<font class="Apple-style-span" color="#fe2b17">str</font>)</div><div> for key, value in section_items:</div><div> value = self._interpolation.before_write(self, section_name, key,</div><div> value)</div><div> if value is not None or not self._allow_no_value:</div><div> value = delimiter + <font class="Apple-style-span" color="#fe2b17">str</font>(value).replace("\n", "\n\t")</div><div> else:</div><div> value = ""</div><div> fp.write("{}{}\n".format(key, value))</div><div> fp.write("\n")</div><div> </div></div><div>Proposed correction:</div><div><div> ### Correction made by D. Latella 28/3/2014</div><div> def _write_section(self, fp, section_name, section_items, delimiter):</div><div> """Write a single section to the specified `fp'."""</div><div> #fp.write("[{}]\n".format(section_name))</div><div> <b><font class="Apple-style-span" color="#fe2b17">strng</font></b> = "[{}]\n".format(section_name)</div><div> fp.write(<b><font class="Apple-style-span" color="#fe2b17">strng</font></b>)</div><div> for key, value in section_items:</div><div> value = self._interpolation.before_write(self, section_name, key,</div><div> value)</div><div> if value is not None or not self._allow_no_value:</div><div> value = delimiter + <b><i><font class="Apple-style-span" color="#00f724">str</font></i></b>(value).replace('\n', '\n\t')</div><div> else:</div><div> value = ""</div><div> fp.write("{}{}\n".format(key, value))</div><div> fp.write("\n")</div></div><div><br></div><div>This is the code to test bug:</div><div><div><br></div><div>import os</div><div>import configparser</div><div><br></div><div>def get_preferences_from_file():</div><div> config = configparser.ConfigParser()</div><div> print(config.sections())</div><div> if not os.access('board.ini',os.F_OK):</div><div> # no .ini file yet, so make one</div><div> config['DEFAULT'] = {'font':'Arial',</div><div> 'size':'12'}</div><div> # Writing our configuration file to 'raven.ini'</div><div> with open('board.ini', 'w') as configfile:</div><div> config.write(configfile)</div><div> config.read('raven.ini')</div><div> print('>>>>',config.sections())</div><div> font = config['DEFAULT']['font']</div><div> size = config['DEFAULT']['size']</div><div> return font, size</div><div><br></div><div>if __name__ == '__main__':</div><div> fs = get_preferences_from_file()</div><div> print(fs)</div></div><div><br></div><div>Best wishes</div><div>Diego Latella</div></div></body></html>