Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#14499 closed (fixed)

ATSocialSecurityNumberField doesn't handle EMPTY_VALUES correctly

Reported by: idangazit Owned by: idangazit
Component: contrib.localflavor Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Fields with required=False should not choke while cleaning any value in EMPTY_VALUES (from django.core.validators):

EMPTY_VALUES = (None, '', [], (), {})

There's at least one case of this in contrib/localflavor/at/forms.py; ATSocialSecurityNumberField; it chokes while cleaning a value of None.

Discovered while porting localflavor's doctests to unittests. In an effort to standardize testing for all of unittest, refactored testing of required vs optional fields to try all values in EMPTY_VALUES, and ran across this issue.

Attachments (1)

14499.diff (840 bytes) - added by idangazit 5 years ago.

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by idangazit

comment:1 Changed 5 years ago by idangazit

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The field in question, ATSocialSecurityNumberField, simply didn't follow the accepted pattern (call super, then check EMPTY_VALUES). Patch attached.

comment:2 Changed 5 years ago by idangazit

  • Summary changed from Some localflavor fields don't handle EMPTY_VALUES correctly to ATSocialSecurityNumberField doesn't handle EMPTY_VALUES correctly

Updating to split instances of this issue into separate tickets.

comment:3 Changed 4 years ago by idangazit

  • Status changed from new to assigned

comment:4 Changed 4 years ago by idangazit

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 4 years ago by Alex

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

(In [14873]) Fixed #14499 -- ATSocialSecurityNumberField now responds to all EMPTY_VALUES correctly. Also converted Austrian localflavor doctests to unittests. We have always been at war with doctests. Thanks to Idan Gazit for the patch.

comment:6 Changed 4 years ago by Alex

(In [14875]) [1.2.X] Fixed #14499 -- ATSocialSecurityNumberField now responds to all EMPTY_VALUES correctly. Also converted Austrian localflavor doctests to unittests. We have always been at war with doctests. Thanks to Idan Gazit for the patch. Backport of [14873].

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