This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Not so correct error message when initializing defaultdict
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: python-dev, rhettinger, vajrasky, zvyn
Priority: low Keywords: patch

Created on 2013-11-20 16:25 by vajrasky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_error_message_default_dict.patch vajrasky, 2013-11-20 16:25 review
Messages (5)
msg203500 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-20 16:25
>>> from collections import defaultdict
>>> defaultdict('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: first argument must be callable
>>> defaultdict(None)
defaultdict(None, {})
>>> None()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable

After patch:

>>> from collections import defaultdict
>>> defaultdict('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: first argument must be callable or None
msg203586 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-11-21 08:46
This is a reasonable patch.  I'll apply it when I have some spare time.
msg246935 - (view) Author: Milan Oberkirch (zvyn) * Date: 2015-07-19 08:59
*ping* This is still a reasonable patch. Would be great if you can apply it :)
msg246966 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-20 07:11
New changeset efda1eaf86a3 by Raymond Hettinger in branch '3.4':
Issue #19663: Improve error message for defaultdict.
https://hg.python.org/cpython/rev/efda1eaf86a3
msg246967 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-07-20 07:13
New changeset d248702feab0 by Raymond Hettinger in branch '2.7':
Issue #19663: Improve error message for defaultdict.
https://hg.python.org/cpython/rev/d248702feab0
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63862
2015-07-20 07:15:06rhettingersetstatus: open -> closed
resolution: fixed
stage: resolved
2015-07-20 07:13:40python-devsetmessages: + msg246967
2015-07-20 07:11:26python-devsetnosy: + python-dev
messages: + msg246966
2015-07-19 08:59:43zvynsetnosy: + zvyn

messages: + msg246935
versions: + Python 3.5, Python 3.6, - Python 3.3
2013-11-21 08:46:01rhettingersetpriority: normal -> low
assignee: rhettinger
messages: + msg203586

versions: + Python 2.7
2013-11-20 16:25:45vajraskycreate