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

PEP 538: Unexpected locale behaviour on *BSD (including Mac OS X) #74857

Open
ncoghlan opened this issue Jun 15, 2017 · 13 comments
Open

PEP 538: Unexpected locale behaviour on *BSD (including Mac OS X) #74857

ncoghlan opened this issue Jun 15, 2017 · 13 comments
Labels
3.7 (EOL) end of life tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@ncoghlan
Copy link
Contributor

BPO 30672
Nosy @ronaldoussoren, @ncoghlan, @ned-deily
PRs
  • WIP bpo-34589: Move locale coercion back to the CLI app #9257
  • Dependencies
  • bpo-30647: CODESET error on AMD64 FreeBSD 10.x Shared 3.x caused by the PEP 538
  • bpo-34589: Py_Initialize() and Py_Main() should not enable C locale coercion
  • 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 = None
    created_at = <Date 2017-06-15.09:23:53.311>
    labels = ['3.7', 'type-bug', 'tests']
    title = 'PEP 538: Unexpected locale behaviour on *BSD (including Mac OS X)'
    updated_at = <Date 2020-06-29.10:36:19.078>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2020-06-29.10:36:19.078>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2017-06-15.09:23:53.311>
    creator = 'ncoghlan'
    dependencies = ['30647', '34589']
    files = []
    hgrepos = []
    issue_num = 30672
    keywords = ['patch']
    message_count = 13.0
    messages = ['296076', '296239', '296248', '296250', '307784', '314646', '314648', '314652', '326710', '354503', '354994', '354995', '372505']
    nosy_count = 3.0
    nosy_names = ['ronaldoussoren', 'ncoghlan', 'ned.deily']
    pr_nums = ['9257']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30672'
    versions = ['Python 3.7']

    @ncoghlan
    Copy link
    Contributor Author

    To get the new PEP-538 tests passing on Mac OS X (see [1,2]), I ended up having to skip the following test scenarios:

        LANG=UTF-8 (behaves like LANG=C, *not* LC_CTYPE=UTF-8)
        LANG=POSIX (behaves like a distinct locale is set, not LANG=C)
        LC_CTYPE=POSIX (behaves like a distinct locale is set, not LANG=C)
        LC_ALL=POSIX (behaves like a distinct locale is set, not LANG=C)

    However, I'm not sure whether that should be diagnosed as a pure testing problem, where we change the test's expectations to match the current behaviour, or a bug in the PEP-538 implementation, where we should be updating it to produce the behaviour that the tests were originally expecting.

    [1] 4563099
    [2] 7926516 )

    @ncoghlan ncoghlan added 3.7 (EOL) end of life tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Jun 15, 2017
    @ncoghlan
    Copy link
    Contributor Author

    For the case where POSIX is a distinct locale from the default C locale (rather than a simple alias), I'm leaning towards taking PEP-538 literally, and adjusting the affected test cases to assume that locale coercion *won't* happen for that case on Mac OS X.

    I *think* we can check for the alias behaviourally by setting the "POSIX" locale and seeing if it reports itself back to us as "C", but if not, then I'll just add in a sys.platform check, and we can figure out a behavioural check later if the platform check turns out to cause problems.

    @ncoghlan
    Copy link
    Contributor Author

    It seems the "POSIX is not just an alias for the C locale" behaviour is inherited from *BSD, rather than being specific to Mac OS X: http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Debug%20custom/builds/12/steps/test/logs/stdio

    @ncoghlan ncoghlan changed the title PEP 538: Unexpected locale behaviour on Mac OS X PEP 538: Unexpected locale behaviour on *BSD (including Mac OS X) Jun 18, 2017
    @ncoghlan
    Copy link
    Contributor Author

    Flagging bpo-30647 as a dependency, since the problem with breaking nl_langinfo will need to be fixed before these tests can be re-enabled.

    @ncoghlan ncoghlan self-assigned this Jun 18, 2017
    @ncoghlan
    Copy link
    Contributor Author

    ncoghlan commented Dec 7, 2017

    As discussed in https://bugs.python.org/issue32238 and https://mail.python.org/pipermail/python-dev/2017-December/151105.html, I now think the right answer for the POSIX case is to ensure the legacy locale detection logic always treats that the same way as it does the C locale.

    LANG=UTF-8 I'm still not sure about - as I understand it, that's a partial locale that only defines LC_CTYPE, which may be why the libc implementation ignores it if you try to set it as a general category default.

    @ncoghlan
    Copy link
    Contributor Author

    Ned, I'd forgotten about the part of this issue which amounts to "Check for 'POSIX' as a locale coercion trigger in addition to 'C', as not every platform aliases the former to the latter the way glibc does".

    So while I don't think this is really a release blocker (as you have to explicitly request the POSIX locale to encounter the discrepancy, and I think fixing it in 3.7.1 would be OK), I *am* bumping it up to "critical", as I think it would be better to resolve this for 3.7.0b4 rather than letting it linger further.

    @ned-deily
    Copy link
    Member

    Thanks for the headsup, Nick. BTW, some of the discussion in languishing bpo-18378 might be relevant here.

    @ncoghlan
    Copy link
    Contributor Author

    The locale module has its own extra layer of oddities that I don't personally understand - bpo-29571 and bpo-20087 are another couple of issues along those lines.

    @ncoghlan
    Copy link
    Contributor Author

    Putting back to normal, as the difference between the C locale and the POSIX locale is that you never get the latter by default - you have to explicitly request it.

    The underlying fix for this is in the PR for bpo-34589.

    @vstinner
    Copy link
    Member

    Since this issue has been created, I deeply reworked the Python Initialization with the PEP-587, and I made many changes related to locales and the UTF-8 Mode (PEP-540). What's the status of this issue?

    @ncoghlan
    Copy link
    Contributor Author

    There are a couple of cases that the C locale coercion tests skip because I don't (or didn't) know what they *should* do:

    With the interpreter explicitly checking for "POSIX" now, at least the latter special case could potentially be removed, with "POSIX" just always being part of the EXPECTED_C_LOCALE_EQUIVALENTS list. (It was only removed because it used to break on FreeBSD and Mac OS X)

    I don't think we ever figured out why the "LANG=UTF-8" case didn't work the way we expected, so I suspect where going to need to keep that skip for now.

    @ncoghlan
    Copy link
    Contributor Author

    (Removed the patch keyword, as the linked PR was for an old change that didn't cover the remaining test issues)

    @ncoghlan
    Copy link
    Contributor Author

    Removing issue assignment, as I'm not actively investigating this.

    @ncoghlan ncoghlan removed their assignment Jun 28, 2020
    @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
    3.7 (EOL) end of life tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    Status: No status
    Development

    No branches or pull requests

    3 participants