[patch] USStateField do_html2python(data) throws exception when data is None
The USStateField do_html2python method calls "upper()" on the data passed to it. If the "data" is None, as it is in the case where you allow users to not select a state (i.e. state is not required), then it calls upper() on "None" which fails.
Patch is simple - test data before returning data.upper(), otherwise just return the data.
Index: formfields.py
===================================================================
--- formfields.py (revision 2292)
+++ formfields.py (working copy)
@@ -875,7 +875,10 @@
raise validators.CriticalValidationError, e.messages
def html2python(data):
- return data.upper() # Should always be stored in upper case
+ if data:
+ return data.upper() # Should always be stored in upper case
+ else:
+ return data
html2python = staticmethod(html2python)
class CommaSeparatedIntegerField(TextField):
Change History
(15)
Summary: |
USStateField do_html2python exception data is None → USStateField do_html2python(data) throws exception when data is None
|
Summary: |
USStateField do_html2python(data) throws exception when data is None → [patch] USStateField do_html2python(data) throws exception when data is None
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Triage Stage: |
Unreviewed → Ready for checkin
|
Resolution: |
fixed
|
Status: |
closed → reopened
|
Triage Stage: |
Ready for checkin → Accepted
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
reopened → closed
|
Patch file against revision 2292 of django/core/formfields.py