Opened 3 weeks ago

Last modified 3 weeks ago

#37102 assigned Bug

CountsDict.__init__() passes *kwargs instead of **kwargs to super().__init__()

Reported by: 王鑫 Owned by: SnippyCodes
Component: Utilities Version: 6.0
Severity: Normal Keywords:
Cc: 王鑫 Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Raffaella)

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.

Change History (8)

comment:1 by Raffaella, 3 weeks ago

Description: modified (diff)

comment:2 by Raffaella, 3 weeks ago

Triage Stage: UnreviewedAccepted

comment:3 by Fergal McCollam, 3 weeks ago

Owner: set to Fergal McCollam
Status: newassigned

comment:4 by Tim Graham, 3 weeks ago

Owner: changed from Fergal McCollam to 王鑫

The report already provided a PR which was automatically closed since the ticket wasn't yet accepted.

comment:5 by Fergal McCollam, 3 weeks ago

Has patch: set

in reply to:  4 comment:6 by Jacob Walls, 3 weeks ago

Owner: 王鑫 removed
Status: assignednew

Replying to 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.

in reply to:  5 comment:7 by Jacob Walls, 3 weeks ago

Replying to 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.)

comment:8 by SnippyCodes, 3 weeks ago

Owner: set to SnippyCodes
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top