#26027: Django model __init__ silently accepts parameters that are also a non-
settable property
-------------------------------+--------------------
     Reporter:  vanschelven    |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.8
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 When passing a keyword argument to a Django model instantiation, when the
 keyword argument also happens to be a non-settable property, this keyword
 argument is silently swallowed and nothing happens.

 This may hide hard-to-track errors. It's also inconsistent (arguments
 which are not non-settable properties give an error like ".... is an
 invalid keyword argument for this function")

 This seems to have been introduced in ancient history:
 
https://github.com/django/django/commit/1fc3b3229a9b137f05a0a49bdc726f8c91317174

 However, looking at the tests that were introduced as a part of that
 particular commit I don't actually see a reason why the try/except block
 would be necessary in the first place (the included tests actually refer
 the opposite scenario, the one were a setter _is_ available). In fact,
 looking at the original test, this particular bug could simply be revealed
 by putting something like

 {{{
 a = Person(full_name = 'Paul McCartney')
 }}}

 In an assertRaises.

 (As of the status quo, this silently does nothing with the value "Paul
 McCartney")

 I would have loved to do the work-proper to reveal the bug with tests; but
 I don't have the time for that now - sorry about that.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.a8dab44c3d291e16eee1fb04c5946480%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to