[Django] #37102: CountsDict.__init__() passes *kwargs instead of **kwargs to super().__init__()

29 views
Skip to first unread message

Django

unread,
May 17, 2026, 4:12:02 AMMay 17
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
----------------------+--------------------------------------
Reporter: 王鑫 | Type: Bug
Status: new | Component: Utilities
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------+--------------------------------------
The CountsDict class in django/utils/html.py has a bug in its __init__
method:

class CountsDict(dict):
def __init__(self, *args, word, **kwargs):
super().__init__(*args, *kwargs) # BUG: should be **kwargs
self.word = word

The call uses *kwargs (positional unpacking) instead of **kwargs
(keyword unpacking). Currently this never triggers because CountsDict is
only called with
word=middle, but it would fail if any keyword arguments were passed.

The fix is to change *kwargs to **kwargs on line 281.
--
Ticket URL: <https://code.djangoproject.com/ticket/37102>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 17, 2026, 3:47:31 PMMay 17
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+--------------------------------------
Reporter: 王鑫 | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Description changed by Raffaella:

Old description:

> The CountsDict class in django/utils/html.py has a bug in its __init__
> method:
>
> class CountsDict(dict):
> def __init__(self, *args, word, **kwargs):
> super().__init__(*args, *kwargs) # BUG: should be **kwargs
> self.word = word
>
> The call uses *kwargs (positional unpacking) instead of **kwargs
> (keyword unpacking). Currently this never triggers because CountsDict is
> only called with
> word=middle, but it would fail if any keyword arguments were passed.
>
> The fix is to change *kwargs to **kwargs on line 281.

New description:

The CountsDict class in django/utils/html.py has a bug in its __init__
method:
{{{#!python
class CountsDict(dict):
def __init__(self, *args, word, **kwargs):
super().__init__(*args, *kwargs) # BUG: should be **kwargs
self.word = word
}}}
The call uses *kwargs (positional unpacking) instead of **kwargs
(keyword unpacking). Currently this never triggers because CountsDict is
only called with
word=middle, but it would fail if any keyword arguments were passed.

The fix is to change *kwargs to **kwargs on line 281.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:1>

Django

unread,
May 17, 2026, 4:01:05 PMMay 17
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+------------------------------------
Reporter: 王鑫 | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Changes (by Raffaella):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:2>

Django

unread,
May 18, 2026, 7:40:04 AMMay 18
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+------------------------------------
Reporter: 王鑫 | Owner: Fergal7
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Changes (by Fergal7):

* owner: (none) => Fergal7
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:3>

Django

unread,
May 18, 2026, 7:44:28 AMMay 18
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+------------------------------------
Reporter: 王鑫 | Owner: 王鑫
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Changes (by Tim Graham):

* owner: Fergal7 => 王鑫

Comment:

The report already provided a PR which was automatically closed since the
ticket wasn't yet accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:4>

Django

unread,
May 18, 2026, 8:17:48 AMMay 18
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+------------------------------------
Reporter: 王鑫 | Owner: 王鑫
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Changes (by Fergal McCollam):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:5>

Django

unread,
May 18, 2026, 5:26:58 PMMay 18
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+------------------------------------
Reporter: 王鑫 | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Changes (by Jacob Walls):

* owner: 王鑫 => (none)
* status: assigned => new

Comment:

Replying to [comment:4 Tim Graham]:
> The report already provided a PR which was automatically closed since
the ticket wasn't yet accepted.

The reporter provided about 6 PRs, some of which I had to manually close
because they deleted the reference to the ticket and mixed in unrelated
typo fixes in an effort to evade the quality bot. I suggest discouraging
the original owner from reassuming ownership. We don't tolerate aggressive
AI agents.
--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:6>

Django

unread,
May 18, 2026, 5:27:55 PMMay 18
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+------------------------------------
Reporter: 王鑫 | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+------------------------------------
Comment (by Jacob Walls):

Replying to [comment:5 Fergal McCollam]:

Thanks for the PR, you can assign to yourself if you wish, but take note
that the provided tests do not fail when run against main, so they aren't
sufficient for a regression test. (You need to pass keyword args besides
`word`.)
--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:7>

Django

unread,
May 19, 2026, 2:49:20 AMMay 19
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+---------------------------------------
Reporter: 王鑫 | Owner: SnippyCodes
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------
Changes (by SnippyCodes):

* owner: (none) => SnippyCodes
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:8>

Django

unread,
Jun 10, 2026, 7:01:17 PMJun 10
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
---------------------------+---------------------------------------------
Reporter: 王鑫 | Owner: SnippyCodes
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+---------------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:9>

Django

unread,
Jun 10, 2026, 7:13:48 PMJun 10
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
-------------------------------------+-------------------------------------
Reporter: 王鑫 | Owner:
Type: | SnippyCodes
Cleanup/optimization | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* type: Bug => Cleanup/optimization

--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:10>

Django

unread,
Jun 10, 2026, 7:14:27 PMJun 10
to django-...@googlegroups.com
#37102: CountsDict.__init__() passes *kwargs instead of **kwargs to
super().__init__()
-------------------------------------+-------------------------------------
Reporter: 王鑫 | Owner:
Type: | SnippyCodes
Cleanup/optimization | Status: closed
Component: Utilities | Version: 6.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"e8cff2921ba169d806a15de18304f431f12700f4" e8cff292]:
{{{#!CommitTicketReference repository=""
revision="e8cff2921ba169d806a15de18304f431f12700f4"
Fixed #37102 -- Used **kwargs instead of *kwargs in CountsDict.__init__().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37102#comment:11>
Reply all
Reply to author
Forward
0 new messages