New submission from TitanSnow <tttnns1...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue32917>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to