Averroes / iniparse

Other
0 stars 0 forks source link

ConfigParse compat mode with a defaults {'foo'=None} returns string 'None' #26

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by alik...@gmail.com on 4 Jan 2011 at 9:17

GoogleCodeExporter commented 9 years ago
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 :)

Original comment by tim.lauridsen on 6 Jan 2011 at 7:45

GoogleCodeExporter commented 9 years ago
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.

Original comment by psobe...@gmail.com on 17 Jun 2012 at 1:14