[New-bugs-announce] [issue41621] defaultdict miss behave when using default_factory passed as kwargs

Moshe Morad report at bugs.python.org
Sun Aug 23 15:04:06 EDT 2020


New submission from Moshe Morad <moshemorad12340 at gmail.com>:

How to reproduce
----------------
>>> from collections import defaultdict
>>> dd = defaultdict(default_factory=list)
>>> dd
defaultdict(None, {'default_factory': <class 'list'>})
>>> print(dd.default_factory)
None


Analysis
--------
defdict_init(PyObject *self, PyObject *args, PyObject *kwds) function that initializing defaultdict object ignores the kwds and pass them to the dict init only.


Expect:
-------
Since we can understand why we want to move kwds to dict without modification consider at least adding comment in the docstring or enforce it as positional argument only.

----------
assignee: docs at python
components: Documentation, ctypes
messages: 375823
nosy: docs at python, moshemorad12340
priority: normal
severity: normal
status: open
title: defaultdict miss behave when using default_factory passed as kwargs
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41621>
_______________________________________


More information about the New-bugs-announce mailing list