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 kirbysdl
Recipients
Date 2003-09-22.21:58:21
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
In my current project, I'm using ConfigParser to read
configuration files as well as manage internal
configuration.  The following test script generates an
error because values of options must be strings in
order for ConfigParser to run smoothly.  (It's short
enough that I'm including it here for reference; I'm
also attaching it).

#----- BEGIN TEST -----
#!/usr/bin/env python

import ConfigParser
import sys

conf = ConfigParser.ConfigParser()
conf.add_section("sect")
conf.set("sect","option",2)
conf.write(sys.stderr)
conf.get("sect","option")
#----- END TEST -----

From the ConfigParser code, I see that the value isn't
checked to make sure it is a string before string
methods are applied to it.

I'm currently using the raw parameter to get() (see
http://www.python.org/doc/lib/ConfigParser-objects.html#l2h-1261)
in order to circumvent the problem.

I'd suggest one or more of the following:
(1) Casting the option to a string explicitly instead
of assuming it is a string (this could also be done in
the set() method).
(2) Checking that the option is a string instead of
assuming it is a string.
(3) Stating in the documentation that the set() method
should only take values of type string.
(4) Stating in the documentation that the raw parameter
should be used when an option's value might not be of
type string (this might be the intended usage, but it
isn't made clear).

I hope none of these are too difficult to implement,
but I understand that this is a noncritical problem. 
Nonetheless, I was shocked to see what I thought was a
straightforward use of ConfigParser throw off errors.  
History
Date User Action Args
2007-08-23 14:16:59adminlinkissue810843 messages
2007-08-23 14:16:59admincreate