[Python-bugs-list] [ python-Bugs-583248 ] ConfigParser spaces in keys not read

noreply@sourceforge.net noreply@sourceforge.net
Wed, 11 Sep 2002 09:50:51 -0700


Bugs item #583248, was opened at 2002-07-18 08:07
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=583248&group_id=5470

Category: Extension Modules
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin Thopmson (martinthompson)
>Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: ConfigParser spaces in keys not read

Initial Comment:
ConfigParser will write, but not read keys with spaces in, eg
key with spaces in = 5
 raises a parse exception.

My fix, tested a small amount on one file!:  
Change regexp on Line 390 to
    OPTCRE = re.compile(
        r'(?P<option>[^=:]+?)'      # anything not an = or :, don;t grab the last space, leave for next bit
        r'[ \t]*(?P<vi>[:=])[ \t]*'           # any number of space/tab,
                                              # followed by separator
                                              # (either : or =), followed
                                              # by any # space/tab
        r'(?P<value>.*)$'                     # everything up to eol
        )




----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-18 22:50

Message:
Logged In: YES 
user_id=80475

Having spaces in the keys does not conflict with the 
documentation for ConfigParser; however, it is inconsistent 
with RFC 822 (which serves as a style guide):

"""The  field-name must be composed of printable ASCII 
characters  (i.e., characters that  have  values  between  
33.  and  126., decimal, except colon)."""

Still, there are valid use cases.  For instance, Windows 
style directory names are potentially useful as keys, yet 
the names allow internal spaces:

[DirectoryAttributes]
My Documents = Hide
My Pictures = Show

Jeremy, do you think multiword keys are the way to go?  If 
so, re-assign to me for implementation in Python 2.3.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=583248&group_id=5470