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 grahamd
Recipients grahamd
Date 2012-04-16.01:57:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334541468.07.0.833607995836.issue14590@psf.upfronthosting.co.za>
In-reply-to
Content
When parsing for inline comments, ConfigParser will only check the first occurrence of the delimiter in the line. If that instance of the delimiter isn't preceded with a space, it then assumes no comment. This ignores the fact that there could be a second instance of the delimiter which does have a preceding space. The result is that inline comments can be left as part of the value.

So, a config file of:

[section]
value1 = a;b
value2 = a ; comment
value3 = a; b ; comment

after parsing actually results in:

[section]
value1 = a;b
value2 = a
value3 = a; b ; comment

That is, 'value3' is incorrect as still embeds the inline comment.

Test script attached for Python 2.X.

Not tested on Python 3.X but code appears to do the same thing, except that on Python 3.X inline comments are disabled by default.
History
Date User Action Args
2012-04-16 01:57:48grahamdsetrecipients: + grahamd
2012-04-16 01:57:48grahamdsetmessageid: <1334541468.07.0.833607995836.issue14590@psf.upfronthosting.co.za>
2012-04-16 01:57:47grahamdlinkissue14590 messages
2012-04-16 01:57:47grahamdcreate