Opened 9 years ago

Closed 9 years ago

#23883 closed Bug (fixed)

flatatt modifies passed in dict, possibly changing the result of subsequent calls

Reported by: Tim Heap Owned by: Claude Paroz <claude@…>
Component: Uncategorized Version: dev
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

The updated django.forms.utils.flatatt function modifies the dict passed in, deleting any boolean attributes it encounters. Calling the function twice using the same dict that contains boolean attributes will thus result in different output, as the boolean attributes have been deleted:

>>> attrs = {'hello': 'world', 'data-true': True, 'data-false': False}
>>> flatatt(attrs)
' hello="world" data-true'
>>> flatatt(attrs)
' hello="world"'

The function should not modify the dict passed in like it does, leaving it unchanged. Fixing this will make the function behave as expected when called with the same dict twice.

Change History (5)

comment:1 Changed 9 years ago by parasgithub

Owner: changed from nobody to parasgithub
Status: newassigned

comment:2 Changed 9 years ago by Tim Heap

A pull request has been created on Github: https://github.com/django/django/pull/3590

comment:3 Changed 9 years ago by parasgithub

Owner: parasgithub deleted
Status: assignednew

comment:4 Changed 9 years ago by Claude Paroz

Has patch: set
Triage Stage: UnreviewedAccepted

comment:5 Changed 9 years ago by Claude Paroz <claude@…>

Owner: set to Claude Paroz <claude@…>
Resolution: fixed
Status: newclosed

In 5b17dcd8ef9c444af2e0a234d708c37b313ef04f:

Fixed #23883 -- Stopped flatatt modifying its argument

Note: See TracTickets for help on using tickets.
Back to Top