classification
Title: calendar.LocaleHTMLCalendar.formatyearpage() results in traceback with 'unsupported locale setting' on Windows
Type: behavior Stage: test needed
Components: Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, ned.deily, r.david.murray, ruseel, skoczian
Priority: normal Keywords: easy, patch

Created on 2010-11-22 02:35 by r.david.murray, last changed 2010-11-24 09:49 by ned.deily.

Files
File name Uploaded Description Edit
issue10498.patch ruseel, 2010-11-24 05:08 patch and unittest
Messages (6)
msg122070 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-22 02:35
See issue 10466 for background, but in short LocaleHTMLCalendar uses getdefaultlocale if no locale is specified, and on windows this results in a locale that setlocale will not accept.  The fix is presumably to use setlocale(LC_DATE, '') instead of getdefaultelocale.
msg122072 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-11-22 02:38
See also #10087.
msg122092 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-11-22 04:29
Fails on OS X as well for similar reasons.
msg122260 - (view) Author: MunSic JEONG (ruseel) Date: 2010-11-24 05:08
On OSX, _locale.setlocale raise locale.Error with arg 'UTF8' but ok with 'UTF-8'. and setlocale tries to normalize localename with locale.normalize(). and locale.normalize() always change encoding to 'UTF8' (locale.py:646). 

So changes in locale.normalize could fix this issue at least on OSX. 

patch and unittest against p3k is attached.



I did not search why normalize() changes 'utf_8' to 'UTF8' until now. but I would post if I get answer in subversion log.
msg122265 - (view) Author: MunSic JEONG (ruseel) Date: 2010-11-24 07:56
r38027 has following changes.

-    'utf-8':                        'UTF-8',
+    'utf_8':                        'UTF8',


subversion log is:

Correct mapping of Python codec name to C encoding name for UTF-8 (the C lib doesn't seem to like "UTF-8").
msg122266 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-11-24 09:49
Your analysis is correct.  Sorry, I should have noted that the OS X "UTF8" vs "UTF-8" discrepancy has already been discussed in Issue10090 and Issue10154.
History
Date User Action Args
2010-11-24 09:49:36ned.deilysetmessages: + msg122266
2010-11-24 07:56:47ruseelsetmessages: + msg122265
2010-11-24 05:08:35ruseelsetfiles: + issue10498.patch
keywords: + patch
messages: + msg122260
2010-11-23 04:36:09ruseelsetnosy: + ruseel
2010-11-22 04:29:05ned.deilysetnosy: + ned.deily
messages: + msg122092
2010-11-22 02:38:58belopolskysetnosy: + belopolsky
messages: + msg122072
2010-11-22 02:37:09r.david.murraysetnosy: + skoczian
2010-11-22 02:35:03r.david.murraycreate