Opened 7 years ago

Closed 6 years ago

#29282 closed Bug (fixed)

Admin checks raise TypeError if issubclass() receives a non-class

Reported by: David Sanders Owned by: Sanyam Khurana
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Herbert Fortes Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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 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.

Change History (10)

comment:1 by Tim Graham, 7 years ago

Description: modified (diff)
Patch needs improvement: set
Summary: Admin Checks May Raise TypeErrorAdmin checks raise TypeError if isinstance() receives a non-class
Triage Stage: UnreviewedAccepted

comment:2 by David Sanders, 7 years ago

Summary: Admin checks raise TypeError if isinstance() receives a non-classAdmin checks raise TypeError if issubclass() receives a non-class

comment:3 by Herbert Fortes, 6 years ago

Cc: Herbert Fortes added

The ticket is quiet for three months.

I read the PR and, only a function name is in a discussion.

I think the ticket was forgotten.

comment:4 by Sanyam Khurana, 6 years ago

Hi David,

I see this ticket is pending for a while. I would help to like out if you're not actively working on this one anymore.

Version 0, edited 6 years ago by Sanyam Khurana (next)

comment:5 by Sanyam Khurana, 6 years ago

Owner: changed from nobody to Sanyam Khurana
Status: newassigned

comment:6 by Tim Graham, 6 years ago

Patch needs improvement: unset

comment:7 by Carlton Gibson, 6 years ago

Triage Stage: AcceptedReady for checkin

Yep. Updated patch looks good.

comment:8 by Carlton Gibson, 6 years ago

Triage Stage: Ready for checkinAccepted

Ooops, I misinterpreted the history from the previous PR. A bit more to do here.

comment:9 by Sanyam Khurana, 6 years ago

Triage Stage: AcceptedReady for checkin

PR updated addressing all the reviews.

https://github.com/django/django/pull/10652/files

comment:10 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In a7d6cab:

Fixed #29282 -- Prevented some admin checks from crashing with TypeError.

Co-authored-by: David Sanders <dsanders11@…>

Note: See TracTickets for help on using tickets.
Back to Top