Menu

#3 Use of set method with keys keywords lead to AttributeError exception

v1.0_(example)
open
nobody
None
5
2014-07-04
2014-07-04
No

After using set methode with keys argument, I've got an exception "AttributeError: 'OptionPair' object has no attribute 'value'" when using get.

How to reproduce:

$ pip show cfgparse | grep Version
Version: 1.3
$ cat test.ini
myOption = myValue
$ python
>>> import cfgparse
>>> parser = cfgparse.ConfigParser()
>>> f = parser.add_file("test.ini")
>>> opt = parser.add_option("myOption")
>>> opt.get()
myValue
>>> opt.set("myOtherValue", cfgfile=f, keys="FOO")
<ConfigFileIni at 0x7f4bd7c65ed0: .../test.ini>
>>> opt.get()
myValue
>>> opt.get(keys="FOO")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../lib/python2.7/site-packages/cfgparse.py", line 685, in get
    value = option.get()
  File "/.../lib/python2.7/site-packages/cfgparse.py", line 561, in get
    return self.value
AttributeError: 'OptionPair' object has no attribute 'value'
>>>

However:

$ cat test.ini
myOption = myValue
[FOO]
myOption = myOtherValue
$ python
>>> import cfgparse
>>> parser = cfgparse.ConfigParser()
>>> f = parser.add_file("test.ini")
>>> opt = parser.add_option("myOption")
>>> opt.get()
myValue
>>> opt.get(keys="FOO")
myOtherValue

Discussion


Log in to post a comment.