Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#11859 closed (fixed)

Change type checking condition in validation of choices

Reported by: paluh Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: model, validation, choices
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I want to use instance of tuple subclass (instead of tuple instance) in IntegerField choices initialization. It's impossible because in core/management/validation.py (line 62) there is condition:

if not type(c) in (tuple, list) or len(c) != 2:

Can it be changed to:

if not (isinstance(c, tuple) or isinstance(c, list)) or len(c) != 2:

Attachments (2)

validation.diff (836 bytes) - added by paluh 7 years ago.
t11859.diff (844 bytes) - added by Alex Gaynor 7 years ago.

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by paluh

Attachment: validation.diff added

comment:1 Changed 7 years ago by Russell Keith-Magee

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Alex Gaynor

Surely you mean isinstance(c, (list, tuple)) ;)

Changed 7 years ago by Alex Gaynor

Attachment: t11859.diff added

comment:3 Changed 7 years ago by Alex Gaynor

Triage Stage: AcceptedReady for checkin

comment:4 Changed 7 years ago by jkocherhans

Resolution: fixed
Status: newclosed

(In [12535]) Fixed #11859. Allowed subclasses of tuple or list for choice options. Thanks, Alex Gaynor.

comment:5 Changed 7 years ago by jkocherhans

(In [12536]) [1.1.X] Fixed #11859. Allowed subclasses of tuple or list for choice options. Backport of r12535 from trunk.

comment:6 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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