Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22539 closed Bug (fixed)

Model.full_clean() mutates exclude argument

Reported by: maggotfish@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

If model.full_clean() gets a list argument for exclude, and after running clean_fields() errors are raised, it appends the names of those fields to the exclude argument, mutating it and causing a really bad side effect which is not expected by the user.

Instead, the list should be copied if it is not None.

Change History (6)

comment:1 by Tim Graham, 11 years ago

Has patch: unset
Triage Stage: UnreviewedAccepted

comment:2 by anonymous, 11 years ago

I have patch ready, shall I send a pull request under a new branch ticket_22539?

comment:3 by Simon Charette, 11 years ago

Yes please, go ahead and make sure to include tests and link the PR to this Trac issue.

comment:4 by maggotfish@…, 11 years ago

Has patch: set

comment:5 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In e2e4cdba1178ebcfd95c19eb063abd55b4afbcbb:

Fixed #22539 -- Copied exclude argument in Model.full_clean() to prevent side effects.

comment:6 by Tim Graham <timograham@…>, 11 years ago

In d56267ba57f28395946fadd6401ad7e1606c3cb0:

[1.7.x] Fixed #22539 -- Copied exclude argument in Model.full_clean() to prevent side effects.

Backport of e2e4cdba11 from master

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