diff -r ee074604bf0c PC/launcher.c --- a/PC/launcher.c Tue Feb 07 11:28:19 2017 +0300 +++ b/PC/launcher.c Wed Feb 08 13:33:50 2017 +0000 @@ -130,13 +130,11 @@ } #if defined(_WINDOWS) - #define PYTHON_EXECUTABLE L"pythonw.exe" - +#define PYTHON_EXECUTABLE_BASE L"pythonw" #else - #define PYTHON_EXECUTABLE L"python.exe" - +#define PYTHON_EXECUTABLE_BASE L"python" #endif #define MAX_VERSION_SIZE 4 @@ -1264,15 +1262,27 @@ error(RC_BAD_VIRTUAL_PATH, L"Unknown virtual \ path '%ls'", command); command += 6; /* skip past "python" */ - if (search && ((*command == L'\0') || isspace(*command))) { - /* Command is eligible for path search, and there - * is no version specification. - */ - debug(L"searching PATH for python executable\n"); - cmd = find_on_path(PYTHON_EXECUTABLE); - debug(L"Python on path: %ls\n", cmd ? cmd->value : L""); + if (*command && !validate_version(command)) + error(RC_BAD_VIRTUAL_PATH, + L"Invalid version specification: '%ls'.\n" + L"In the first line of the script, 'python' " + L"needs to be followed by a valid version " + L"specifier.\nPlease check the " + L"documentation.", + command); + if (search) { + /* Command is eligible for path search. */ + wchar_t name[BUFSIZE]; + _snwprintf_s(name, BUFSIZE, _TRUNCATE, + L"%ls%ls.exe", PYTHON_EXECUTABLE_BASE, command); + debug(L"searching PATH for python executable: " + L"%ls\n", name); + cmd = find_on_path(name); + debug(L"Python on path: %ls\n", cmd ? cmd->value : + L""); if (cmd) { - debug(L"located python on PATH: %ls\n", cmd->value); + debug(L"located python on PATH: %ls\n", + cmd->value); invoke_child(cmd->value, suffix, cmdline); /* Exit here, as we have found the command */ return; @@ -1281,12 +1291,6 @@ * back to locating the correct installed python. */ } - if (*command && !validate_version(command)) - error(RC_BAD_VIRTUAL_PATH, L"Invalid version \ -specification: '%ls'.\nIn the first line of the script, 'python' needs to be \ -followed by a valid version specifier.\nPlease check the documentation.", - command); - /* TODO could call validate_version(command) */ ip = locate_python(command, TRUE); if (ip == NULL) { error(RC_NO_PYTHON, L"Requested Python version \