This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author The Compiler
Recipients The Compiler, lukasz.langa
Date 2014-05-13.14:47:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1399992449.17.0.699994077825.issue21498@psf.upfronthosting.co.za>
In-reply-to
Content
When adding something to a configparser instance which has a key beginning with a comment char, it writes the data to a file without generating an error, and when reading the file back obviously the data is different as it's a comment:

    >>> cp = configparser.ConfigParser()
    >>> cp.read_dict({'DEFAULT': {';foo': 'bar'}})
    >>> cp.write(sys.stdout)
    [DEFAULT]
    ;foo = bar

This was discussed on python-dev here:
https://mail.python.org/pipermail/python-dev/2014-April/134293.html

Of course there are other corner cases as well, like having a key like "[foo]" or "=bar".

I think whatever data I pass into a configparser should also come out again when reading the file back.

Since there's no escaping in configparser, I think the ideal solution would be configparser refusing to write ambigious values.

While this is technically a backwards-incompatible change, applications doing this were broken in the first place, so validation while writing will not break anything.

Validating when setting values would be better of course, but this can potentially break applications where configparser is used without actually writing a file.
History
Date User Action Args
2014-05-13 14:47:29The Compilersetrecipients: + The Compiler, lukasz.langa
2014-05-13 14:47:29The Compilersetmessageid: <1399992449.17.0.699994077825.issue21498@psf.upfronthosting.co.za>
2014-05-13 14:47:29The Compilerlinkissue21498 messages
2014-05-13 14:47:28The Compilercreate