﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29135	get_object_or_404() and get_list_or_404() swallow AttributeError in queryset filtering	David Hagen	Yuri Shikanov	"Here is the code for `get_list_or_404`:

{{{
def get_list_or_404(klass, *args, **kwargs):
    queryset = _get_queryset(klass)
    try:
        obj_list = list(queryset.filter(*args, **kwargs))
    except AttributeError:
        klass__name = klass.__name__ if isinstance(klass, type) else klass.__class__.__name__
        raise ValueError(
            ""First argument to get_list_or_404() must be a Model, Manager, or ""
            ""QuerySet, not '%s'."" % klass__name
        )
    if not obj_list:
        raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
    return obj_list
}}}

The try-catch block is far too broad. Any `AttributeError` raised during the call to `filter` is swallowed and converted into an incorrect and confusing error message. This should be changed to either `if not hasattr(queryset, 'filter'): raise ...` or `try: method = queryset.filter; except AttributeError: ...`. The same thing happens with `queryset.get(*args, **kwargs)` in `get_object_or_404`'."	Cleanup/optimization	closed	Core (Other)	dev	Normal	fixed			Ready for checkin	1	0	0	0	1	0
