[Django] #22539: Model.full_clean() mutates exclude argument

15 views
Skip to first unread message

Django

unread,
Apr 29, 2014, 5:48:04 AM4/29/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
----------------------------------------------+--------------------
Reporter: maggotfish@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
----------------------------------------------+--------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/22539>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 29, 2014, 6:55:03 AM4/29/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
-------------------------------------+-------------------------------------

Reporter: maggotfish@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* has_patch: 1 => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


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

Django

unread,
Apr 29, 2014, 6:58:14 AM4/29/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
-------------------------------------+-------------------------------------

Reporter: maggotfish@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

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

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

Django

unread,
Apr 29, 2014, 11:00:50 AM4/29/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
-------------------------------------+-------------------------------------

Reporter: maggotfish@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by charettes):

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

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

Django

unread,
May 1, 2014, 7:53:38 AM5/1/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
-------------------------------------+-------------------------------------

Reporter: maggotfish@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by maggotfish@…):

* has_patch: 0 => 1


Comment:

PR here: https://github.com/django/django/pull/2622

--
Ticket URL: <https://code.djangoproject.com/ticket/22539#comment:4>

Django

unread,
May 1, 2014, 9:29:21 AM5/1/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
-------------------------------------+-------------------------------------
Reporter: maggotfish@… | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"e2e4cdba1178ebcfd95c19eb063abd55b4afbcbb"]:
{{{
#!CommitTicketReference repository=""
revision="e2e4cdba1178ebcfd95c19eb063abd55b4afbcbb"
Fixed #22539 -- Copied exclude argument in Model.full_clean() to prevent
side effects.
}}}

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

Django

unread,
May 1, 2014, 9:36:47 AM5/1/14
to django-...@googlegroups.com
#22539: Model.full_clean() mutates exclude argument
-------------------------------------+-------------------------------------
Reporter: maggotfish@… | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d56267ba57f28395946fadd6401ad7e1606c3cb0"]:
{{{
#!CommitTicketReference repository=""
revision="d56267ba57f28395946fadd6401ad7e1606c3cb0"
[1.7.x] Fixed #22539 -- Copied exclude argument in Model.full_clean() to
prevent side effects.

Backport of e2e4cdba11 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22539#comment:6>

Reply all
Reply to author
Forward
0 new messages