This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients asvetlov, ezio.melotti, gklein, jcea, jkloth, pitrou, python-dev, serhiy.storchaka, skrah, tim.golden, turncc, vstinner
Date 2012-11-05.08:16:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The test is still failing on Mac OS X:

FAIL: test_non_ascii (test.test_cmd_line_script.CmdLineTest)
Traceback (most recent call last):
  File "/Volumes/bay2/buildslave/cpython/3.x.snakebite-mountainlion-amd64/build/Lib/test/", line 380, in test_non_ascii
    rc, stdout, stderr = assert_python_ok(script_name)
  File "/Volumes/bay2/buildslave/cpython/3.x.snakebite-mountainlion-amd64/build/Lib/test/", line 54, in assert_python_ok
    return _assert_python(True, *args, **env_vars)
  File "/Volumes/bay2/buildslave/cpython/3.x.snakebite-mountainlion-amd64/build/Lib/test/", line 46, in _assert_python
    "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
AssertionError: Process return code is 2, stderr follows:
/Volumes/bay2/buildslave/cpython/3.x.snakebite-mountainlion-amd64/build/python.exe: can't open file './': [Errno 2] No such file or directory


If I remember correctly, the command line is always decoded from UTF-8/surrogateescape on Mac OS X. That's why we have the function _Py_DecodeUTF8_surrogateescape() (for bootstrap reasons).

Such example should not work if the locale encoding is not UTF-8 on Mac OS X:
arg = _Py_DecodeUTF8_surrogateescape(...);
filename = _Py_wchar2char(arg);
fp = fopen(filename, "r");

run_file() uses a different strategy:

        unicode = PyUnicode_FromWideChar(filename, wcslen(filename));
        if (unicode != NULL) {
            bytes = PyUnicode_EncodeFSDefault(unicode);
        if (bytes != NULL)
            filename_str = PyBytes_AsString(bytes);
        else {
            filename_str = "<encoding error>";

run_file() looks to be right. Py_Main() should use similar code.

We should probably not encode and then decode the filename in each function, but this is another problem.
Date User Action Args
2012-11-05 08:16:55vstinnersetrecipients: + vstinner, jcea, pitrou, tim.golden, jkloth, ezio.melotti, asvetlov, skrah, gklein, python-dev, serhiy.storchaka, turncc
2012-11-05 08:16:55vstinnersetmessageid: <>
2012-11-05 08:16:55vstinnerlinkissue16218 messages
2012-11-05 08:16:54vstinnercreate