Opened 18 years ago
Closed 17 years ago
#3509 closed (invalid)
[patch] django.newforms.util.smart_unicode() is not smart enough :)
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Guys
django.newforms.util.smart_unicode() needs to be smarter to don't unicode None, True and False values and leave them as they are.
The patch is attached.
Attachments (1)
Change History (6)
by , 18 years ago
Attachment: | smart_unicode_fix.patch added |
---|
comment:1 by , 18 years ago
Summary: | django.newforms.util.smart_unicode() is not smart enough :) → [patch] django.newforms.util.smart_unicode() is not smart enough :) |
---|
Sorry, forgot to name the subject properly.
As I always do :)
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
It's true that something needs to change so that unicode(s, settings.DEFAULT_CHARSET)
doesn't choke on these types, but smart_unicode
looks like it should always return a unicode object. Perhaps just str(s)
if it's type is NoneType
or bool
.
comment:3 by , 18 years ago
smart_unicode(None) -> u'None' -> try to save it in DB and guess what happened
same is for smart_unicode(True) -> u'True' -> same thing
comment:4 by , 18 years ago
Can you give an example of where the current behaviour is causing errors?
smart_unicode() is an equivalent of str() and unicode() in that it forces the result to be a string, intentionally. So not converting certain types is counter-intuitive behaviour.
Are there cases in the code where we are calling smart_unicode() on booleans or None and then expecting them to act as their original types? Those cases should be fixed, but the general fix in this ticket is not the right way to do it.
comment:5 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Quick fix