[Python-bugs-list] [ python-Bugs-592527 ] comments taken as values in ConfigParser

noreply@sourceforge.net noreply@sourceforge.net
Thu, 08 Aug 2002 03:11:19 -0700


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

Category: Python Library
Group: 3rd Party
Status: Open
Resolution: None
Priority: 5
Submitted By: Artūras Kriukovas (drugelis)
Assigned to: Nobody/Anonymous (nobody)
Summary: comments taken as values in ConfigParser

Initial Comment:
Let's say we have config file config.conf with contents:


[forms]
....
myParameter = myValue # my comment here :) 
# and my comment here
....

[other sections]
.......


We run python code:

    import sys, os
    from ConfigParser import *
    fileLocations = ['......./config.conf']
    parser = ConfigParser()
    parser.read(fileLocations)
    parser.sections()

and when we run:
    parser.get('forms', 'manoParameter')

we get:
    'myValue # my comment here :)'

The comment is also included as key value. The second
comment is left out as it should be.
The simpliest way to fix it probaby would be remove all
string after the first '#' char (that is to leave
string part to first '#' char).

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

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