Issue 26 in iniparse: ConfigParse compat mode with a defaults {'foo'=None} returns string 'None'

3 views
Skip to first unread message

inip...@googlecode.com

unread,
Jan 4, 2011, 4:18:38 PM1/4/11
to iniparse...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 26 by alikins: ConfigParse compat mode with a defaults
{'foo'=None} returns string 'None'
http://code.google.com/p/iniparse/issues/detail?id=26

What steps will reproduce the problem?

With a 'test.ini' like:
[test]
foo = blip


and code like:

from iniparse import SafeConfigParser

defaults = {'foo':'bar', 'blip': None}
cp = SafeConfigParser(defaults = defaults)
cp.read('test.ini')
a = cp.get('test', 'blip')
print a, type(a)


What is the expected output? What do you see instead?

ConfigParser.SafeConfigParser will return None in this case

What version of the product are you using? On what operating system?
python-iniparse-0.4-2.fc14.noarch, python 2.7

Please provide any additional information below.

inip...@googlecode.com

unread,
Jan 6, 2011, 2:46:00 AM1/6/11
to iniparse...@googlegroups.com

Comment #1 on issue 26 by tim.lauridsen: ConfigParse compat mode with a
defaults {'foo'=None} returns string 'None'
http://code.google.com/p/iniparse/issues/detail?id=26

I can reproduce it. (python 2.7)

ConfigParser.SafeConfigParser will return None

and iniparse will return 'None'

But it is a little tricky because you can't write a None type to an ini
file and get it back as a None type. So the your can get a None value in a
default dict, but not from reading from a real ini file. So you can discuss
if it a bug in ConfigParser to able to set a default value, that is a
differnt type that the one you can read from an ini file (string, int &
boolean)

Put anyway if iniparse should be compatible with Configparser, then it
should act in the same way :)

inip...@googlecode.com

unread,
Jun 17, 2012, 9:14:49 AM6/17/12
to iniparse...@googlegroups.com

Comment #2 on issue 26 by psobe...@gmail.com: ConfigParse compat mode with
a defaults {'foo'=None} returns string 'None'
http://code.google.com/p/iniparse/issues/detail?id=26

iniparse has specific support for this behavior when non-string values are
assigned to attributes (as far as I can remember). We should be able to
get this to work with defaults as well.

Reply all
Reply to author
Forward
0 new messages