Opened 18 years ago
Closed 16 years ago
#4380 closed (wontfix)
Rename DEFAULT_CHARSET to OUTPUT_CHARSET (or similar)
Reported by: | Simon Willison | Owned by: | ctrochalakis |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | ||
Cc: | floguy@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Just spotted this in the new unicode documentation (from the unicode branch):
Do not be fooled into thinking that if you
DEFAULT_CHARSET
setting is set
to something other thanutf-8
you can use that encoding in your
bytestrings! TheDEFAULT_CHARSET
only applies to the strings generated as
the result of template rendering (and email). Django will always assume UTF-8
encoding for internal bytestrings. The reason for this is that the
DEFAULT_CHARSET
setting is not actually under your control (if you are the
application developer). It is under the control of the person installing and
using your application and if they choose a different setting, your code must
still continue to work. Ergo, it cannot rely on that setting.
http://code.djangoproject.com/browser/django/branches/unicode/docs/unicode.txt?rev=5330#L57
How about renaming that setting to something more clear, like OUTPUT_CHARSET or DEFAULT_OUTPUT_CHARSET?
Attachments (4)
Change History (15)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 18 years ago
Well, that'll teach me to document things.
Might be worth changing for all the good reasons you mention. I thought about it, particularly when writing that passage, because it brings the unfortunate name into relief. On a theoretical level, I'm completely in agreement. But I hate making backwards incompatible changes. If we can fake a backwards compatible hack (e.g. populate OUTPUT_CHARSET from DEFAULT_CHARSET if the former doesn't exist in the settings module), I'd be happier. That's probably achievable, without thinking too hard about it.
I'm probably in favour, but I need some time to get used to it. :-)
Best plan of all: convince Adrian and/or Jacob so that I can avoid making a decision.
Marc: FILE_CHARSET was already discussed ad infinitum on django-dev. It's not going to change because it's not just used for template input (and that fact is even documented - look at the documentation for FILE_CHARSET in settings.txt).
comment:3 by , 17 years ago
Triage Stage: | Design decision needed → Accepted |
---|
A bit of a wart, but I think I'm vaguely +0 on deprecating DEFAULT_CHARSET and switching to OUTPUT_CHARSET since Malcolm assures me that could be done in a backwards-compatible way.
comment:4 by , 17 years ago
Version: | other branch → SVN |
---|
comment:5 by , 17 years ago
Cc: | added |
---|---|
Has patch: | set |
Needs documentation: | set |
Owner: | changed from | to
Status: | new → assigned |
by , 17 years ago
Attachment: | default_charset_deprecation.1.diff added |
---|
Replaced all DEFAULT_CHARSET references with OUTPUT_CHARSET, and added PendingDeprecationWarnings for referencing DEFAULT_CHARSET.
by , 17 years ago
Attachment: | 0001-Replace-DEFAULT_CHARSET-with-OUTPUT_CHARSET.patch added |
---|
replace-DEFAULT_CHARSET
comment:6 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
That second patch is cleaner than my first one.
by , 17 years ago
Attachment: | 0001-Replace-DEFAULT_CHARSET-with-OUTPUT_CHARSET.2.patch added |
---|
replace-DEFAULT_CHARSET+deprecation warning
comment:7 by , 17 years ago
Added a deprecation warning as Eric did in the first patch. The warning is triggered if the DEFAULT_CHARSET is set.
comment:8 by , 17 years ago
At a minimum there needs be a "New in Django develpoment version" marker in the settings documentation. I'd also leave a docs entry in place for DEFAULT_CHARSET and refer it to OUTPUT_CHARSET with a note that this was the older way of doing it. That way people reading the docs and searching for the setting they have in their code will still find an entry.
comment:9 by , 17 years ago
Needs documentation: | unset |
---|---|
Patch needs improvement: | set |
by , 17 years ago
Attachment: | output_charset.patch added |
---|
comment:10 by , 17 years ago
Patch needs improvement: | unset |
---|
Added a "new in development version" marker. Also, DEFAULT_CHARSET section in retained in the settings.txt file, and refers to OUTPUT_CHARSET.
comment:11 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Not worth it now. We're going to have to support DEFAULT_CHARSET
for a long time now that 1.0 is coming out and it doesn't seem to be causing a lot of confusion to people. Yes, I probably should have just fixed this when it was first raised, but I didn't. Sorry, but can't go back in time (time machine is only for bug fixes, not a cure for sloth).
+1 at least the setting will be a bit clearer on its purpose ;)
Maybe FILE_CHARSET could be moved to TEMPLATE_CHARSET as it only affects templates ;))
but you'd rather bring that to django-devs ;)