#10335: tzinfo.py should use getdefaultencoding instead of getdefaultlocale[1]
----------------------------------------------+-----------------------------
Reporter: gthb | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: 1.0
Keywords: locale encoding getdefaultlocale | Stage: Unreviewed
Has_patch: 1 |
----------------------------------------------+-----------------------------
In some locales on Mac OS X, page rendering fails with an error like:
{{{
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5
/site-packages/django/template/debug.py", line 81, in render_node
raise wrapped
TemplateSyntaxError: Caught an exception while rendering: unknown
encoding: mac-icelandic
}}}
(where the encoding varies, could be mac-roman or other Mac-specific
encodings)
It turns out that Python does not recognize some Mac-specific encodings,
including those that are default in some locales (such as our Icelandic
one).
That should be okay, we would just configure Python or Django to use a
different default encoding. But the trouble is, we can't. In tzinfo.py the
default encoding is determined as locale.getdefaultlocale()[1], which
calls _locale._getdefaultlocale(), which on a Mac calls
CFStringGetSystemEncoding. Of this latter function, the Mac documentation
says:
''In Mac OS X, this encoding is determined by the user's preferred
language setting. The preferred language is the first language listed in
the International pane of the System Preferences.''
So there appears to be no way, in some locales, to get Django to render
pages. One is forced to change the user's global language preference in
the operating system settings. That's a bit too inflexible.
In contrast, sys.getdefaultencoding is easily controlled by calling
sys.setdefaultencoding in sitecustomize.py.
Thus tzinfo.py should obtain the default encoding using
sys.getdefaultencoding instead — at least optionally, or perhaps as a
special-case exception for the mac-specific encodings, if one wants to
take great care to minimize behavior changes in working installations.
--
Ticket URL: <http://code.djangoproject.com/ticket/10335>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---