Permalink
Browse files

Removed a bare except following Django's behaviour

  • Loading branch information...
1 parent 4ab2825 commit b0d29546f5b28534579acd2a01f466b1193667f4 @brutasse brutasse committed Sep 25, 2012
Showing with 6 additions and 8 deletions.
  1. +6 −8 floppyforms/widgets.py
View
14 floppyforms/widgets.py
@@ -370,21 +370,19 @@ class PhoneNumberInput(Input):
input_type = 'tel'
+def boolean_check(v):
+ return not (v is False or v is None or v == '')
+
+
class CheckboxInput(Input, forms.CheckboxInput):
input_type = 'checkbox'
def __init__(self, attrs=None, check_test=None):
super(CheckboxInput, self).__init__(attrs)
- if check_test is None:
- check_test = lambda v: not (v is False or v is None or v == '')
- self.check_test = check_test
+ self.check_test = boolean_check if check_test is None else check_test
def get_context(self, name, value, attrs):
- result = False
- try:
- result = self.check_test(value)
- except: # That bare except is in the Django code...
- pass
+ result = self.check_test(value)
context = super(CheckboxInput, self).get_context(name, value, attrs)
if result:
context['attrs']['checked'] = True

0 comments on commit b0d2954

Please sign in to comment.