This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Calendar Problem with Windows (XP)
Type: compile error Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)
View: 10466
Assigned To: Nosy List: Juebo, r.david.murray
Priority: normal Keywords:

Created on 2014-06-12 11:38 by Juebo, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg220341 - (view) Author: Jürgen B (Juebo) Date: 2014-06-12 11:38
I had a problem with calendar.formatmonth()
Error message was 'Unsupported Locale'

Well, it seems that Windows (XP) does nothing accept to setlocale than ''

I changed /lib/calendar.py line 488 ff to
class different_locale:
    def __init__(self, locale):
        self.locale = locale

    def __enter__(self):
        _locale.setlocale(_locale.LC_TIME, '') # juebo
        self.oldlocale = _locale.getlocale(_locale.LC_TIME)
        # _locale.setlocale(_locale.LC_TIME, self.locale) # juebo

    def __exit__(self, *args):
        # _locale.setlocale(_locale.LC_TIME, self.oldlocale) #juebo
        _locale.setlocale(_locale.LC_TIME, '')

Well, I am absolute new to Python. So could anybody look over it
msg220347 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-06-12 13:14
The code is mostly correct as it exists in the calendar module.  You are running into issue 10466.  Per my comment in that issue, it may be possible to put a workaround into the calendar module, but your suggestion isn't it, since your code would leave the locale modified, not restored to its value before the calendar function was called.

What happens if you replace the original setlocale call in __enter__ with a try/except, and if the set fails, redo the set call using ''?  Does the save of oldlocale and its restore work in that case?
msg220352 - (view) Author: Jürgen B (Juebo) Date: 2014-06-12 13:42
Yes, Issue 10466 seems to be the same problem. One could fix this one instance higher, not necessarily in Calendar.py.

As I said, I have "no idea" about Python (not yet). You could code this and I would test it.
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65930
2021-12-06 23:44:20iritkatrielsetstatus: open -> closed
superseder: locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)
resolution: duplicate
stage: resolved
2014-06-12 13:42:01Juebosetmessages: + msg220352
2014-06-12 13:36:00r.david.murraylinkissue10498 superseder
2014-06-12 13:14:49r.david.murraysetnosy: + r.david.murray
messages: + msg220347
2014-06-12 11:38:21Juebocreate