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

Test_idle should stop changing locale #71559

Closed
terryjreedy opened this issue Jun 22, 2016 · 3 comments
Closed

Test_idle should stop changing locale #71559

terryjreedy opened this issue Jun 22, 2016 · 3 comments
Assignees
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 27372
Nosy @terryjreedy, @serhiy-storchaka
PRs
  • [3.5] bpo-27372: Stop test_idle from changing locale, so test passes. #1397
  • Files
  • locale-change.diff
  • locale-change2.diff
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2016-06-26.21:49:20.097>
    created_at = <Date 2016-06-22.21:04:29.285>
    labels = ['expert-IDLE', 'type-bug']
    title = 'Test_idle should stop changing locale'
    updated_at = <Date 2019-03-21.04:53:55.720>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-03-21.04:53:55.720>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-06-26.21:49:20.097>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2016-06-22.21:04:29.285>
    creator = 'terry.reedy'
    dependencies = []
    files = ['43516', '43548']
    hgrepos = []
    issue_num = 27372
    keywords = ['patch']
    message_count = 3.0
    messages = ['269087', '269318', '269319']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'python-dev', 'serhiy.storchaka']
    pr_nums = ['1397']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27372'
    versions = ['Python 3.6']

    @terryjreedy
    Copy link
    Member Author

    test.test_idle has long resulted in warnings about the locale being changed. In 3.6, this warning causes test_idle to be tagged a failure. Though this does not (yet) turn the overall run of a buildbot from green to red, it is annoying to have success reported as a failure.

    The culprit is in iomenu: locale.setlocale(locale.LC_CTYPE, "") Commenting it out removed the warning and tests pass. But I don't know the real effect, if it would work for tests on all systems, and the consequence when running IDLE normally.

    The problem cannot be monkey-patched away since the damage is done on import. Instead I added 'testing = False' to idlelib.__init__, made test_idle change it to True, and replace the locale-encoding code with "encoding = 'utf-8'" when testing is True.

    Serhiy, I *think* this is ready. However, another eagle-eye review would be welcome. Tests also pass with 'ascii'. Would that be better?

    ---
    Side note: the locale and encoding code could use a review from someone who knows more that me. For instance, suppressing ImportError here:

    try:
        import locale
        locale.setlocale(locale.LC_CTYPE, "")
    except (ImportError, locale.Error):
        pass
    

    guarantees a NameError a few lines further. There is another chunk labelled deprecated, and more might be obsolete in 3.x. But this is another issue.

    @terryjreedy terryjreedy self-assigned this Jun 22, 2016
    @terryjreedy terryjreedy added the type-bug An unexpected behavior, bug, or error label Jun 22, 2016
    @terryjreedy
    Copy link
    Member Author

    Added a couple of blank lines and expanded a comment.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 26, 2016

    New changeset 3ffdb9277054 by Terry Jan Reedy in branch 'default':
    bpo-27372: Stop test_idle from changing locale, so test passes.
    https://hg.python.org/cpython/rev/3ffdb9277054

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

    No branches or pull requests

    1 participant