classification
Title: TypeError: dict is not callable in ConfigParser.py
Type: Stage:
Components: Library (Lib) Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: czhenry, ethan.furman
Priority: normal Keywords:

Created on 2013-05-17 19:49 by czhenry, last changed 2013-05-17 21:10 by ethan.furman. This issue is now closed.

Messages (2)
msg189480 - (view) Author: Charles Henry (czhenry) Date: 2013-05-17 19:49
Python 2.6 and 2.7 each have a bad definition of the class RawConfigParser
It is immediately apparent in the __init__ function which begins with:

class RawConfigParser:
    def __init__(self, defaults=None, dict_type=dict):
        self._dict = dict_type
        self._sections = self._dict()
        self._defaults = self._dict()

Clearly, _dict() is not a function.  _dict is not even properly defined as a public or private member of the RawConfigParser class.

The fix is to add a private variable to the class and a function for retrieving the value.
msg189486 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2013-05-17 21:10
Your interest if fixing Python is appreciated, but you need to verify that a bug actually exists first:

Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
--> class RawConfigParser:
...     def __init__(self, defaults=None, dict_type=dict):
...         self._dict = dict_type
...         self._sections = self._dict()
...         self._defaults = self._dict()
... 
--> rcp = RawConfigParser()
--> rcp._sections
{}
--> type(rcp._sections)
<type 'dict'>
--> rcp._sections['test'] = 'hello, world!'
--> rcp._sections
{'test': 'hello, world!'}

As you can see, it is indeed callable and does result in a dictionary.
History
Date User Action Args
2013-05-17 21:10:22ethan.furmansetstatus: open -> closed
resolution: not a bug
messages: + msg189486
2013-05-17 20:38:30ethan.furmansetnosy: + ethan.furman
2013-05-17 19:49:55czhenrycreate