Issue #18 resolved

py launcher didn't support .py files under path contains non-ASCII(Unicode) characters.

Yonggang Luo
created an issue

py launcher didn't support .py files under path contains non-ASCII(Unicode) characters.

Comments (12)

  1. Yonggang Luo reporter

    Create a directory with Chinese characters.

    D:\中文路径\

    and create a test.py under with path

    D:\中文路径\test.py

    this file is a simple hello world program. double click this file, it's will be failed when execute.

  2. Vinay Sajip

    This is not a launcher issue: it's because Python 2.x can't cope with filenames with Unicode: Python 3 works fine. I created two files in a directory c:\temp\中文路径 - one called test.py (no shebang) and one called test3.py (with a shebang of #!python3. The scripts run when the Python 3 shebang is present, but not otherwise. The screenshot illustrates:

    screenshot

    Notice in the last command I ran the no-shebang script with Python 3, with no problems.

    I'll mark this as resolved, please re-open with more information if you disagree.

  3. Vinay Sajip

    As expected, it behaves the same way when I use double-click to try running the scripts. The Python 2 script doesn't run, but the Python 3 one does. If you have Python 3 installed, why don't you try it and report your findings?

  4. Yonggang Luo reporter
    C:\Users\LYG>cd /d D:\A B\桌面
    
    D:\A B\桌面>hello.py
    python: failed to set __main__.__loader__
    
    D:\A B\桌面>py -3 hello.py
    hello
    
    D:\A B\桌面>cat hello.py
    #!/usr/bin/env python3
    print('hello')
    D:\A B\桌面>
    

    The path should contains both space and non-ASCII characters.

  5. Vinay Sajip

    Thanks for the additional info, but I am unable to reproduce this problem. See this screenshot:

    screenshot

    Please set the environment variable PYLAUNCH_DEBUG using

    set PYLAUNCH_DEBUG=True

    and re-run the scripts which cause the failure, then post your findings here (the environment variable will cause extra information to be printed out).

    Thanks.

  6. Yonggang Luo reporter
    D:\A B\桌面>set PYLAUNCH_DEBUG=True
    
    D:\A B\桌面>type hello.py
    #!/usr/bin/env python3
    print('hello')
    D:\A B\桌面>hello.py
    launcher build: 32bit
    launcher executable: Console
    File 'C:\Users\LYG\AppData\Local\py.ini' non-existent
    File 'C:\Windows\py.ini' non-existent
    Called with command line: "D:\A B\??\hello.py" maybe_handle_shebang: read 38 bytes
    maybe_handle_shebang: BOM not found, using UTF-8
    parse_shebang: found command: python3
    locating Pythons in 64bit registry
    locate_pythons_for_key: unable to open PythonCore key in HKCU
    locate_pythons_for_key: unable to open PythonCore key in HKLM
    locating Pythons in native registry
    locate_pythons_for_key: unable to open PythonCore key in HKCU
    locate_pythons_for_key: C:\Python24\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python24\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python24\PCBuild\amd64\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python25\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python25\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python25\PCBuild\amd64\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python26\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python26\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python26\PCBuild\amd64\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python27\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python27\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python27\PCBuild\amd64\python.exe: The system cannot find the path specified.
    HKLM\SOFTWARE\Python\PythonCore\3.2\InstallPath: The system cannot find the file specified.
    locate_pythons_for_key: C:\Python33\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python33\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python33\PCBuild\amd64\python.exe: The system cannot find the path specified.
    found no configured value for 'python3'
    search for Python version '3' found 'C:\Python33\python.exe'
    run_child: about to run 'C:\Python33\python.exe "D:\A B\??\hello.py" '
    python: failed to set __main__.__loader__
    child process exit code: 1
    
    D:\A B\桌面>py hello.py
    launcher build: 32bit
    launcher executable: Console
    File 'C:\Users\LYG\AppData\Local\py.ini' non-existent
    File 'C:\Windows\py.ini' non-existent
    Called with command line: hello.pymaybe_handle_shebang: read 38 bytes
    maybe_handle_shebang: BOM not found, using UTF-8
    parse_shebang: found command: python3
    locating Pythons in 64bit registry
    locate_pythons_for_key: unable to open PythonCore key in HKCU
    locate_pythons_for_key: unable to open PythonCore key in HKLM
    locating Pythons in native registry
    locate_pythons_for_key: unable to open PythonCore key in HKCU
    locate_pythons_for_key: C:\Python24\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python24\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python24\PCBuild\amd64\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python25\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python25\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python25\PCBuild\amd64\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python26\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python26\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python26\PCBuild\amd64\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python27\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python27\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python27\PCBuild\amd64\python.exe: The system cannot find the path specified.
    HKLM\SOFTWARE\Python\PythonCore\3.2\InstallPath: The system cannot find the file specified.
    locate_pythons_for_key: C:\Python33\python.exe is a 32bit executable
    locate_pythons_for_key: C:\Python33\PCBuild\python.exe: The system cannot find the path specified.
    locate_pythons_for_key: C:\Python33\PCBuild\amd64\python.exe: The system cannot find the path specified.
    found no configured value for 'python3'
    search for Python version '3' found 'C:\Python33\python.exe'
    run_child: about to run 'C:\Python33\python.exe hello.py'
    hello
    child process exit code: 0
    
    D:\A B\桌面>
    
  7. Yonggang Luo reporter

    It's looks like the problem of Python 3. it's didn't support Unicode path as input path. anyway, please notice the different between different ANSI code page, the running result should be different, my code page is CP936(GBK, Simplified-Chinese)

  8. Log in to comment