#23555: QuerySet.first suppresses internal IndexError exceptions
-------------------------------------+-------------------------------------
     Reporter:  artemrizhov          |      Owner:  nobody
         Type:  Bug                  |     Status:  new
    Component:  Database layer       |    Version:  master
  (models, ORM)                      |   Keywords:  QuerySet first
     Severity:  Normal               |  IndexError
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 Current implementation of this method relies on `IndexError` when checking
 the item existence. However this exception may be raised somewhere inside
 of own `__getitem__()` which does a lot of work. This way the potential
 errors are hidden. The method will return `None` in case of a bug that
 raises `IndexError` internally. The Zen of Python says "Errors should
 never pass silently."

 
https://github.com/django/django/blob/e9103402c0fa873aea58a6a11dba510cd308cb84/django/db/models/query.py#L515

--
Ticket URL: <https://code.djangoproject.com/ticket/23555>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.f751add3c9b242ffc798237a725594c6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to