larsks / iniparse

Automatically exported from code.google.com/p/iniparse
Other
0 stars 0 forks source link

ValueError on cfg.defaults() #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. print("cfg.defaults: %s" %(cfg.defaults()))

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

Expected: options and values of [DEFAULT]

Instead:

Traceback (most recent call last):
  File "C:\PyPrg\dev\_testiniparse.py", line 32, in <module>
    print("cfg.defaults: %s" %(cfg.defaults()))
  File "C:\Python\lib\site-packages\iniparse\compat.py", line 40, in defaults
    for name, lineobj in self.data._defaults._options:
ValueError: too many values to unpack

What version of the product are you using? On what operating system?
Python-2.6 / iniparse-0.2.4

Please provide any additional information below.

Possible solution in compat.py, class RawConfigParser:

    def defaults(self):
        d = {}
        # next line, .items() inserted!
        for name, lineobj in self.data._defaults._options.items():
            d[name] = lineobj.value
        return d

Original issue reported on code.google.com by j-th...@web.de on 10 Feb 2009 at 10:43

GoogleCodeExporter commented 9 years ago
Wow, I guess I've never actually executed the defaults() method.  I'm surprised
Python's ConfigParser unit tests didn't catch this one.

Original comment by psobe...@gmail.com on 22 Feb 2009 at 7:44

GoogleCodeExporter commented 9 years ago
fixed in revision 108

Original comment by psobe...@gmail.com on 22 Feb 2009 at 9:35