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 Kunjesh.Kaushik
Recipients Kunjesh.Kaushik
Date 2011-01-27.14:37:04
SpamBayes Score 7.928265e-07
Marked as misclassified No
Message-id <1296139025.05.0.619488294513.issue11027@psf.upfronthosting.co.za>
In-reply-to
Content
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(
History
Date User Action Args
2011-01-27 14:37:05Kunjesh.Kaushiksetrecipients: + Kunjesh.Kaushik
2011-01-27 14:37:05Kunjesh.Kaushiksetmessageid: <1296139025.05.0.619488294513.issue11027@psf.upfronthosting.co.za>
2011-01-27 14:37:04Kunjesh.Kaushiklinkissue11027 messages
2011-01-27 14:37:04Kunjesh.Kaushikcreate