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.LocaleHTMLCalendar.formatyearpage() results in traceback with 'unsupported locale setting' on Windows #54707

Closed
bitdancer opened this issue Nov 22, 2010 · 7 comments
Labels
easy type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 10498
Nosy @abalkin, @ned-deily, @bitdancer
Superseder
  • bpo-21731: Calendar Problem with Windows (XP)
  • Files
  • issue10498.patch: patch and unittest
  • 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 2014-06-12.13:36:00.209>
    created_at = <Date 2010-11-22.02:35:03.387>
    labels = ['easy', 'type-bug']
    title = "calendar.LocaleHTMLCalendar.formatyearpage() results in traceback with 'unsupported locale setting' on Windows"
    updated_at = <Date 2014-06-12.13:36:00.208>
    user = 'https://github.com/bitdancer'

    bugs.python.org fields:

    activity = <Date 2014-06-12.13:36:00.208>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-06-12.13:36:00.209>
    closer = 'r.david.murray'
    components = []
    creation = <Date 2010-11-22.02:35:03.387>
    creator = 'r.david.murray'
    dependencies = []
    files = ['19793']
    hgrepos = []
    issue_num = 10498
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['122070', '122072', '122092', '122260', '122265', '122266', '220351']
    nosy_count = 5.0
    nosy_names = ['belopolsky', 'ruseel', 'ned.deily', 'r.david.murray', 'skoczian']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '21731'
    type = 'behavior'
    url = 'https://bugs.python.org/issue10498'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @bitdancer
    Copy link
    Member Author

    See bpo-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.

    @bitdancer bitdancer added easy type-bug An unexpected behavior, bug, or error labels Nov 22, 2010
    @abalkin
    Copy link
    Member

    abalkin commented Nov 22, 2010

    See also bpo-10087.

    @ned-deily
    Copy link
    Member

    Fails on OS X as well for similar reasons.

    @ruseel
    Copy link
    Mannequin

    ruseel mannequin commented Nov 24, 2010

    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.

    @ruseel
    Copy link
    Mannequin

    ruseel mannequin commented Nov 24, 2010

    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").

    @ned-deily
    Copy link
    Member

    Your analysis is correct. Sorry, I should have noted that the OS X "UTF8" vs "UTF-8" discrepancy has already been discussed in bpo-10090 and bpo-10154.

    @bitdancer
    Copy link
    Member Author

    I'm closing this in favor of bpo-21731, which has a proposed (though I believe incorrect) patch.

    @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
    easy type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants