Opened 10 years ago

Closed 10 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 by parasgithub, 10 years ago

Owner: changed from nobody to parasgithub
Status: newassigned

comment:2 by Tim Heap, 10 years ago

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

comment:3 by parasgithub, 10 years ago

Owner: parasgithub removed
Status: assignednew

comment:4 by Claude Paroz, 10 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:5 by Claude Paroz <claude@…>, 10 years ago

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