New submission from Kunjesh Kaushik <kunjesh.kaus...@gmail.com>: It is often desirable to be able to write a section with spaces around the header, as in "[ default ]" instead of "[default]" for the sake of readability of configuration file. I am not sure if this is the "standard" format of configuration files.
The following (attached) patch will achieve the desired result. It is also backward-compatible. Kindly arrange for the patch to be applied to the repository or to a future release. Original Code Location: http://svn.python.org/view/*checkout*/python/branches/release27-maint/Lib/ConfigParser.py?revision=84443 Index: Lib/ConfigParser.py =================================================================== --- Lib/ConfigParser.py (revision 84443) +++ Lib/ConfigParser.py (working copy) @@ -432,7 +432,7 @@ # SECTCRE = re.compile( r'\[' # [ - r'(?P<header>[^]]+)' # very permissive! + r'\s*(?P<header>[^]]+)\s*' # very permissive! r'\]' # ] ) OPTCRE = re.compile( ---------- components: Library (Lib) files: allow_spaces_around_section_header.diff keywords: patch messages: 127193 nosy: Kunjesh.Kaushik priority: normal severity: normal status: open title: Allow spaces around section header in ConfigParser type: feature request versions: Python 2.7 Added file: http://bugs.python.org/file20547/allow_spaces_around_section_header.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11027> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com