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_subprocess test_undecodable_env error on AIX #55402

Closed
sable mannequin opened this issue Feb 11, 2011 · 12 comments
Closed

test_subprocess test_undecodable_env error on AIX #55402

sable mannequin opened this issue Feb 11, 2011 · 12 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@sable
Copy link
Mannequin

sable mannequin commented Feb 11, 2011

BPO 11193
Nosy @gpshead, @pitrou, @vstinner, @aixtools
PRs
  • bpo-11193: Remove special handeling for AIX in test_subprocess.test_undecodable_env #8939
  • [3.7] bpo-11193: Remove AIX workaround test_subprocess (GH-8939) #8946
  • 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 2018-08-26.17:31:29.594>
    created_at = <Date 2011-02-11.15:28:17.132>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7']
    title = 'test_subprocess test_undecodable_env error on AIX'
    updated_at = <Date 2018-08-27.00:19:42.255>
    user = 'https://bugs.python.org/sable'

    bugs.python.org fields:

    activity = <Date 2018-08-27.00:19:42.255>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-08-26.17:31:29.594>
    closer = 'gregory.p.smith'
    components = ['Interpreter Core']
    creation = <Date 2011-02-11.15:28:17.132>
    creator = 'sable'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 11193
    keywords = ['patch']
    message_count = 12.0
    messages = ['128402', '128403', '128406', '128543', '128548', '128549', '128555', '184314', '271281', '324117', '324128', '324130']
    nosy_count = 6.0
    nosy_names = ['gregory.p.smith', 'pitrou', 'vstinner', 'sable', 'David.Edelsohn', 'Michael.Felt']
    pr_nums = ['8939', '8946']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11193'
    versions = ['Python 3.7', 'Python 3.8']

    @sable
    Copy link
    Mannequin Author

    sable mannequin commented Feb 11, 2011

    The following tests fail in test_subprocess on AIX:

    ======================================================================
    FAIL: test_undecodable_env (test.test_subprocess.POSIXProcessTestCase)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/san_cis/home/cis/.buildbot/python-aix6/3.x.phenix.xlc/build/Lib/test/test_subprocess.py", line 1039, in test_undecodable_env
        self.assertEqual(stdout.decode('ascii'), ascii(value))
    AssertionError: "'abc\\xff'" != "'abc\\udcff'"
    - 'abc\xff'
    ?      ^
    + 'abc\udcff'
    ?      ^^^

    ======================================================================
    FAIL: test_undecodable_env (test.test_subprocess.ProcessTestCasePOSIXPurePython)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/san_cis/home/cis/.buildbot/python-aix6/3.x.phenix.xlc/build/Lib/test/test_subprocess.py", line 1039, in test_undecodable_env
        self.assertEqual(stdout.decode('ascii'), ascii(value))
    AssertionError: "'abc\\xff'" != "'abc\\udcff'"
    - 'abc\xff'
    ?      ^
    + 'abc\udcff'
    ?      ^^^

    Ran 267 tests in 366.280s

    FAILED (failures=2, skipped=22)

    I haven't investigated yet.

    @pitrou
    Copy link
    Member

    pitrou commented Feb 11, 2011

    Perhaps related to the test_locale failure in bpo-11190.

    @vstinner
    Copy link
    Member

    test_undecodable_code() in test_cmd_line had a similar issue: on FreeBSD, Solaris and Mac OS X, even if the locale is C (and nl_langinfo(CODESET) announces ASCII), _Py_char2wchar() (mbstowcs) decoded b'\xff' as '\xff' (use ISO-8859-1 encoding). To fix the test, I just patched the test to accept both results: b'\xff' may be decoded as '\udcff' or '\xff'.

    test_undecodable_env does something like: os.environb[b'test']=b'abc\xff', but os.getenv() decodes b'abc\xff' as 'abc\xff' instead of 'abc\udcff' even if LC_ALL=C.

    I don't understand why the test pass on FreeBSD, Solaris and Mac OS X, but not on AIX. It would be interesting to get the locale encoding of the child process using LC_ALL=C.

    @vstinner
    Copy link
    Member

    I don't understand why the test pass on FreeBSD, Solaris and
    Mac OS X, but not on AIX.

    Oh, the command line and the filesystem encodings may be different. test_undecodable_env() of test_subprocess.py uses os.environ which uses sys.getfilesystemencoding(), whereas test_undecodable_code() of test_cmd_line.py uses _Py_char2wchar() which uses mbstowcs() functions (which use the locale encoding).

    sys.getfilesystemencoding() is initialized from nl_langinfo(CODESET).

    nl_langinfo(CODESET) gives maybe "ISO-8859-1" (or an alias to this encoding) even if LC_ALL=C.

    @sable
    Copy link
    Mannequin Author

    sable mannequin commented Feb 14, 2011

    I am not sure this is what you want:

    > LC_ALL=C ./python
    Python 3.2rc3 (py3k:88417M, Feb 14 2011, 10:37:42) 
    [GCC 4.2.0] on aix6
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.getfilesystemencoding()
    'iso8859-1'
    >>> 

    What information can I provide to help solve this bug?

    @vstinner
    Copy link
    Member

    >>> sys.getfilesystemencoding()
    'iso8859-1'

    Ok, I expected this result.

    Can you also try:

    $ LC_ALL=C ./python -c "import sys; print(ascii(sys.argv))" $(echo -ne "abc\xff")
    ['-c', 'abc\udcff']
    $ LC_ALL=C python3.1 -c "import locale; print(locale.nl_langinfo(locale.CODESET))"
    ANSI_X3.4-1968
    $ LC_ALL=C python3.1 -c "import locale; print(locale.getpreferredencoding())"
    ANSI_X3.4-1968

    Anyway, test_undecodable_env() is not written to support ISO-8859-1 filesystem encoding. I should patch the test to check the filesystem encoding.

    @sable
    Copy link
    Mannequin Author

    sable mannequin commented Feb 14, 2011

    $ LANG=C ./python -Wd -E -bb -c "import sys; print(ascii(sys.argv))" $(echo -ne "abc\xff")['-c', 'abc\xff']
    ['-c', 'abc\xff']
    $ LANG=C ./python -Wd -E -bb -c "import locale; print(locale.nl_langinfo(locale.CODESET))"
    ISO8859-1
    $ LANG=C ./python -Wd -E -bb -c "import locale; print(locale.getpreferredencoding())"
    ISO8859-1

    @vstinner
    Copy link
    Member

    ping myself

    @DavidEdelsohn DavidEdelsohn mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 19, 2013
    @aixtools
    Copy link
    Contributor

    Seems to be okay at least with Python 3.6 "test" version - but maybe there is better way to call these tests - just to be sure the one needed is not being skipped.

    On AIX 5.3 TL7 SP0:

    root@x064:[/data/prj/aixtools/python/python-3.6.0.162/Lib/test]../../python test_subprocess.py
    ssss...........................................s.......................................................s.....s.........s...............................................................s.....s.........s.........................................sssssssssssss
    ----------------------------------------------------------------------
    Ran 254 tests in 113.796s

    OK (skipped=24)

    On AIX 6.1 TL9 SP4:

    michael@x071:[/data/prj/aixtools/python/python-3.6.0.162/Lib/test]../../python test_subprocess.py
    ssss...........................................s.......................................................s.....s.........s...............................................................s.....s.........s.........................................sssssssssssss
    ----------------------------------------------------------------------
    Ran 254 tests in 126.684s

    OK (skipped=24)
    michael@x071:[/data/prj/aixtools/python/python-3.6.0.162/Lib/test]

    Please note that GNU libiconv is used by default (version 1.14) rather than IBM iconv.

    This may be the key issue (will test 11190 as well)

    @aixtools
    Copy link
    Contributor

    Short Version:
    root@x065:[/data/prj/python/python3-3.8]./python -m test test_subprocess
    Run tests sequentially
    0:00:00 [1/1] test_subprocess
    test_subprocess passed in 2 min 18 sec

    == Tests result: SUCCESS ==

    1 test OK.

    Total duration: 2 min 18 sec
    Tests result: SUCCESS

    ...
    ----------------------------------------------------------------------
    Ran 285 tests in 136.443s

    OK (skipped=33)
    test_subprocess passed in 2 min 16 sec

    == Tests result: SUCCESS ==

    1 test OK.

    Total duration: 2 min 16 sec
    Tests result: SUCCESS

    Posting a PR - tested manually on AIX 5.3, AIX 6.1 and AIX 7.1

    imho: being able to remove the special condition for AIX is an improvement.

    diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
    index 73b57b21db..4719773b67 100644
    --- a/Lib/test/test_subprocess.py
    +++ b/Lib/test/test_subprocess.py
    @@ -2228,15 +2228,9 @@ class POSIXProcessTestCase(BaseTestCase):
                 env = os.environ.copy()
                 env[key] = value
                 # Use C locale to get ASCII for the locale encoding to force
    -            # surrogate-escaping of \xFF in the child process; otherwise it can
    -            # be decoded as-is if the default locale is latin-1.
    +            # surrogate-escaping of \xFF in the child process
                 env['LC_ALL'] = 'C'
    -            if sys.platform.startswith("aix"):
    -                # On AIX, the C locale uses the Latin1 encoding
    -                decoded_value = encoded_value.decode("latin1", "surrogateescape")
    -            else:
    -                # On other UNIXes, the C locale uses the ASCII encoding
    -                decoded_value = value
    +            decoded_value = value
                 stdout = subprocess.check_output(
                     [sys.executable, "-c", script],
                     env=env)

    @aixtools aixtools added the 3.8 (EOL) end of life label Aug 26, 2018
    @gpshead
    Copy link
    Member

    gpshead commented Aug 26, 2018

    someone with modern AIX access reopen if this specific issue still appears to exist after the 3.8 and 3.7 PRs finish merging.

    @gpshead gpshead added the 3.7 (EOL) end of life label Aug 26, 2018
    @gpshead gpshead closed this as completed Aug 26, 2018
    @gpshead gpshead changed the title test_subprocess error on AIX test_subprocess test_undecodable_env error on AIX Aug 26, 2018
    @gpshead
    Copy link
    Member

    gpshead commented Aug 26, 2018

    #8939 and #8946

    @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 3.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants