Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar Problem with Windows (XP) #65930

Closed
Juebo mannequin opened this issue Jun 12, 2014 · 3 comments
Closed

Calendar Problem with Windows (XP) #65930

Juebo mannequin opened this issue Jun 12, 2014 · 3 comments
Labels
build The build process and cross-build stdlib Python modules in the Lib dir

Comments

@Juebo
Copy link
Mannequin

Juebo mannequin commented Jun 12, 2014

BPO 21731
Nosy @bitdancer
Superseder
  • bpo-10466: locale.py resetlocale throws exception on Windows (getdefaultlocale returns value not usable in setlocale)
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-12-06.23:44:20.004>
    created_at = <Date 2014-06-12.11:38:21.155>
    labels = ['build', 'library']
    title = 'Calendar Problem with Windows (XP)'
    updated_at = <Date 2021-12-06.23:44:20.004>
    user = 'https://bugs.python.org/Juebo'

    bugs.python.org fields:

    activity = <Date 2021-12-06.23:44:20.004>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-06.23:44:20.004>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2014-06-12.11:38:21.155>
    creator = 'Juebo'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 21731
    keywords = []
    message_count = 3.0
    messages = ['220341', '220347', '220352']
    nosy_count = 2.0
    nosy_names = ['r.david.murray', 'Juebo']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '10466'
    type = 'compile error'
    url = 'https://bugs.python.org/issue21731'
    versions = ['Python 2.7', 'Python 3.4']

    @Juebo
    Copy link
    Mannequin Author

    Juebo mannequin commented Jun 12, 2014

    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

    @Juebo Juebo mannequin added stdlib Python modules in the Lib dir build The build process and cross-build labels Jun 12, 2014
    @bitdancer
    Copy link
    Member

    The code is mostly correct as it exists in the calendar module. You are running into bpo-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?

    @Juebo
    Copy link
    Mannequin Author

    Juebo mannequin commented Jun 12, 2014

    Yes, bpo-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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants