[Django] #22640: Can create model instance with conflicting args and kwargs value for the same field

40 views
Skip to first unread message

Django

unread,
May 16, 2014, 12:14:28 PM5/16/14
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
----------------------------------------------+--------------------
Reporter: zsoldosp | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Discovered while working on #18586

To reproduce it, add the following test (it's using
tests.basic.models.Article)
{{{#!python
def test_cannot_specify_same_field_with_args_and_kwargs_too(self):
six.assertRaisesRegex(
self,
TypeError,
"'foo' is an invalid keyword argument for this function",
Article,
None, # id
'args based headline',
headline='kwargs based headline',
pub_date=datetime(2005, 7, 31),
)
}}}

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

Django

unread,
May 16, 2014, 8:00:08 PM5/16/14
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------

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

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

For what it's worth, I didn't realize there was any attempt to support
positional arguments in model instantiation (although it is tested, is it
documented anywhere?). May not be worth fixing, in my opinion.

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

Django

unread,
May 17, 2014, 4:39:11 AM5/17/14
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------
Reporter: zsoldosp | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Hi,

From what I understand, `*args` instanciation is there for performance
reasons (see [1]).

I'll accept this ticket on the basis that it'd be nice to fix it but only
if it doesn't impact performance negatively.

Thanks.

[1]

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

Django

unread,
May 20, 2014, 6:51:02 AM5/20/14
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------
Reporter: zsoldosp | Owner: nobody

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

Comment (by zsoldosp):

Apologies, I've kept the wrong text message in the original test-repro,
that will have to change to "{{{__init__}}} got multiple values for
keyword argument 'headline'"

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

Django

unread,
Jan 17, 2017, 4:50:29 PM1/17/17
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------
Reporter: Peter Zsoldos | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Anton Samarchyan:

Old description:

> Discovered while working on #18586
>
> To reproduce it, add the following test (it's using
> tests.basic.models.Article)
> {{{#!python
> def test_cannot_specify_same_field_with_args_and_kwargs_too(self):
> six.assertRaisesRegex(
> self,
> TypeError,
> "'foo' is an invalid keyword argument for this function",
> Article,
> None, # id
> 'args based headline',
> headline='kwargs based headline',
> pub_date=datetime(2005, 7, 31),
> )
> }}}

New description:

Discovered while working on #18586

To reproduce it, add the following test (it's using
tests.basic.models.Article)
{{{#!python

from django.utils import six


def test_cannot_specify_same_field_with_args_and_kwargs_too(self):
six.assertRaisesRegex(
self,
TypeError,

"__init__() got multiple values for argument 'headline'",


Article,
None, # id
'args based headline',
headline='kwargs based headline',
pub_date=datetime(2005, 7, 31),
)
}}}

--

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

Django

unread,
Feb 27, 2021, 7:22:58 PM2/27/21
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------
Reporter: Peter Zsoldos | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* owner: nobody => Jacob Walls
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/14059 PR]

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

Django

unread,
Mar 1, 2021, 2:28:49 PM3/1/21
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------
Reporter: Peter Zsoldos | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Mar 1, 2021, 4:01:10 PM3/1/21
to django-...@googlegroups.com
#22640: Can create model instance with conflicting args and kwargs value for the
same field
-------------------------------------+-------------------------------------
Reporter: Peter Zsoldos | Owner: Jacob
Type: | Walls
Cleanup/optimization | Status: closed

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

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"73b1b225ce1a3318d4478f90cc0db0a260aba3aa" 73b1b225]:
{{{
#!CommitTicketReference repository=""
revision="73b1b225ce1a3318d4478f90cc0db0a260aba3aa"
Fixed #22640 -- Raised TypeError when instantiating model with keyword and
positional args for the same field.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22640#comment:7>

Reply all
Reply to author
Forward
0 new messages