Opened 6 years ago

Closed 5 years ago

Last modified 4 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 6 years ago.
t11859.diff (844 bytes) - added by Alex 5 years ago.

Download all attachments as: .zip

Change History (8)

Changed 6 years ago by paluh

comment:1 Changed 5 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by Alex

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

Changed 5 years ago by Alex

comment:3 Changed 5 years ago by Alex

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 5 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:5 Changed 5 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 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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