[New-bugs-announce] [issue32917] ConfigParser writes a superfluous final blank line
TitanSnow
report at bugs.python.org
Thu Feb 22 20:29:50 EST 2018
New submission from TitanSnow <tttnns1024 at gmail.com>:
``ConfigParser.write()`` writes a superfluous final blank line.
Example::
import configparser
cp = configparser.ConfigParser()
cp['section1'] = {'key': 'value'}
cp['section2'] = {'key': 'value'}
with open('configparser.ini', 'w') as f:
cp.write(f)
The output file 'configparser.ini' will be:: (I added line number)
1 [section1]
2 key = value
3
4 [section2]
5 key = value
6
with a superfluous final blank line.
Compare to ``GLib.KeyFile``::
import gi
gi.require_version('GLib', '2.0')
from gi.repository import GLib
kf = GLib.KeyFile()
kf.set_string('section1', 'key', 'value')
kf.set_string('section2', 'key', 'value')
kf.save_to_file('glib.ini')
The output file 'glib.ini' will be:: (I added line number)
1 [section1]
2 key=value
3
4 [section2]
5 key=value
without a superfluous final blank line.
----------
components: Library (Lib)
files: final_blank_line.patch
keywords: patch
messages: 312608
nosy: tttnns
priority: normal
severity: normal
status: open
title: ConfigParser writes a superfluous final blank line
type: behavior
Added file: https://bugs.python.org/file47460/final_blank_line.patch
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32917>
_______________________________________
More information about the New-bugs-announce
mailing list