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 lannert
Recipients
Date 2002-04-26.12:00:30
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Each configuration file parsed by ConfigParser.py must
start
with a section header line (a section name enclosed in
[...]).
In many cases where I just want to parse a file with
some
variable settings for a program this is IMO a nuisance:
The
user must know the expected section name and insert a
redundant header line, even if there are no other
sections
possible.

The "surprise factor" is even higher when RFC[2]822
syntax
is used; the config file then looks more like a
standard mail
header which wouldn't start with a section title
anyway.

Since the config file is read and the case of missing
section
titles handled in the __read() method of the
ConfigParser,
there is no easy way to modify the parser's behaviour
just
by subclassing and overwriting a method.

The patch lets the caller specify a default section
name; if
the config file doesn't start with a [section] line but
with
option lines, a suitable section is automatically
created and
holds the option entries. In any other case, i.e., when
the
header line is present in the config file and/or when
no
default startsection name is specified, the parser's
behaviour
is unchanged. Thus there shouldn't be a compatibility
issue.

In case the upload of the patch file fails (which has
happened
to me and my browser before), please have a look at
<http://starship.python.net/~lannert/ConfigParser.diff>;
the
diffs also add some lines to test_cfgparser.py.
History
Date User Action Args
2007-08-23 15:12:29adminlinkissue549037 messages
2007-08-23 15:12:29admincreate