Menu

#1209 [SciTE][windows]Support to execute python file in output window

Committed
closed
5
2018-05-14
2018-02-05
Liang Bai
No

Description:
In the output window, I enter
pe++.py test.cpp
and expect to execute this python script, but it failed and said
%1 is not a valid Win32 application.

Root cause:
In DWORD SciTEWin::ExecuteOne(const Job &jobToRun), when the executable file is a python script, the first call of CreateProcessW will fail and the error code is ERROR_BAD_EXE_FORMAT. The current implementation only try to call CreateProcessW with prefix "cmd.exe /c " when the error code is ERROR_FILE_NOT_FOUND.

Possible fix:
Also try to call CreateProcessW with prefix "cmd.exe /c " if the error code is ERROR_BAD_EXE_FORMAT.

Possible fix code:

    DWORD errCode = ::GetLastError();
    // if jobCLI "System can't find" or "Bad exe format" - try calling with command processor
    if ((!running) && (jobToRun.jobType == jobCLI) && (errCode == ERROR_FILE_NOT_FOUND || errCode == ERROR_BAD_EXE_FORMAT)) {

Discussion

  • Neil Hodgson

    Neil Hodgson - 2018-02-08
    • labels: --> scite, win32
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2018-02-08

    I'm not seeing this on Windows 10 1709 Fall Creators Update with Python 3.6.1 and current repository SciTE or SciTE 4.0.2. It does initially return ERROR_FILE_NOT_FOUND so gets rerun with cmd/c.

    With this script saved into pe++.py:

    import sys
    print("a", sys.argv)
    

    Running it by typing "pe++.py test.cpp" gives these results:

    pe++.py test.cpp
    >pe++.py test.cpp
    a ['C:\\u\\hg\\pe++.py', 'test.cpp']
    >Exit code: 0
    

    Its possible that the .py extension is not associated with Python.exe on your machine maybe due to installation or reinstallation or permissioning issues.

     
  • Liang Bai

    Liang Bai - 2018-02-09

    Thanks for your reply. I checked and found that I missed something in the description. Here is the steps:
    1. Add D:\usr\bin to PATH environment variable.
    2. Put pe++.py under D:\usr\bin.
    3. Copy pe++.py to D:\, the new name is pe++a.py.
    4. Open D:\test.c.
    5. In the output window: you can run pe++a.py successfully while railed to run pe++.py.

     
  • Neil Hodgson

    Neil Hodgson - 2018-02-16
    • Group: Completed --> Committed
     
  • Neil Hodgson

    Neil Hodgson - 2018-02-16

    Committed change as [47bbc6].

     

    Related

    Commit: [47bbc6]

  • Neil Hodgson

    Neil Hodgson - 2018-05-14
    • status: open --> closed
     

Log in to post a comment.