Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#11859 closed (fixed)

Change type checking condition in validation of choices

Reported by: paluh Owned by: nobody
Component: Core (Other) Version: dev
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: no UI/UX: no

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 15 years ago.
t11859.diff (844 bytes ) - added by Alex Gaynor 15 years ago.

Download all attachments as: .zip

Change History (8)

by paluh, 15 years ago

Attachment: validation.diff added

comment:1 by Russell Keith-Magee, 15 years ago

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:2 by Alex Gaynor, 15 years ago

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

by Alex Gaynor, 15 years ago

Attachment: t11859.diff added

comment:3 by Alex Gaynor, 15 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by jkocherhans, 15 years ago

Resolution: fixed
Status: newclosed

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

comment:5 by jkocherhans, 15 years ago

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

comment:6 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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