Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: dict is not callable in ConfigParser.py #62201

Closed
czhenry mannequin opened this issue May 17, 2013 · 2 comments
Closed

TypeError: dict is not callable in ConfigParser.py #62201

czhenry mannequin opened this issue May 17, 2013 · 2 comments
Labels
stdlib Python modules in the Lib dir

Comments

@czhenry
Copy link
Mannequin

czhenry mannequin commented May 17, 2013

BPO 18001
Nosy @ethanfurman

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-05-17.21:10:22.970>
created_at = <Date 2013-05-17.19:49:55.239>
labels = ['invalid', 'library']
title = 'TypeError: dict is not callable in ConfigParser.py'
updated_at = <Date 2013-05-17.21:10:22.968>
user = 'https://bugs.python.org/czhenry'

bugs.python.org fields:

activity = <Date 2013-05-17.21:10:22.968>
actor = 'ethan.furman'
assignee = 'none'
closed = True
closed_date = <Date 2013-05-17.21:10:22.970>
closer = 'ethan.furman'
components = ['Library (Lib)']
creation = <Date 2013-05-17.19:49:55.239>
creator = 'czhenry'
dependencies = []
files = []
hgrepos = []
issue_num = 18001
keywords = []
message_count = 2.0
messages = ['189480', '189486']
nosy_count = 2.0
nosy_names = ['ethan.furman', 'czhenry']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue18001'
versions = ['Python 2.6', 'Python 2.7']

@czhenry
Copy link
Mannequin Author

czhenry mannequin commented May 17, 2013

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.

@czhenry czhenry mannequin added the stdlib Python modules in the Lib dir label May 17, 2013
@ethanfurman
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant