#29282: Admin checks raise TypeError if isinstance() receives a non-class
-------------------------------+------------------------------------
     Reporter:  David Sanders  |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  contrib.admin  |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  1
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1
 * stage:  Unreviewed => Accepted


Old description:

> Admin checks include several calls to `issubclass` without a
> `try`/`catch`, allowing a `TypeError` to escape if the user provides a
> value that isn't a `class` for whatever is being checked. This seems like
> a sane-enough edge case to ensure the user gets a useful check failed
> message rather than an uncaught exception. Providing a PR that uses a
> helper function that catches the `TypeError` and returns `False` instead
> so that the half-dozen checks that use `issubclass` have minimal code
> change.

New description:

 Admin checks include several calls to `issubclass` without a
 `try`/`catch`, allowing a `TypeError` to escape if the user provides a
 value that isn't a `class` for whatever is being checked. This seems like
 a sane-enough edge case to ensure the user gets a useful check failed
 message rather than an uncaught exception. My
 [https://github.com/django/django/pull/9844 PR] uses a helper function
 that catches the `TypeError` and returns `False` instead so that the half-
 dozen checks that use `issubclass` have minimal code change.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29282#comment:1>
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/068.d0ff09ed8d4f720dc13310e3fee8c98f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to