[issue11027] Allow spaces around section header in ConfigParser

Kunjesh Kaushik report at bugs.python.org
Thu Jan 27 20:33:08 CET 2011


Kunjesh Kaushik <kunjesh.kaushik at gmail.com> added the comment:

Mr. Raymond has raised a valid point. On second thought, I think the submitted patch won't resolve the issue.

>>> import re
>>> r = re.compile(r'\[\s*(?P<header>[^]]+)\s*\]') # as in the patch
>>> r.match('[ section header ]').group('header')  # still has issues
'section header '

ISTM, the only solution to this problem is to strip the section headers while parsing the file. Subsequent access mechanism should also follow suit. IMHO, section headers should be made case-insensitive as well -- similar to option keys.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11027>
_______________________________________


More information about the Python-bugs-list mailing list