New submission from Graham Dumpleton <graham.dumple...@gmail.com>: 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. ---------- components: Library (Lib) files: test_config.py messages: 158397 nosy: grahamd priority: normal severity: normal status: open title: ConfigParser doesn't strip inline comment when delimiter occurs earlier without preceding space. type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file25233/test_config.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14590> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com