From 435bad6fde970b7fab6d24032ee3d6d86a00d22e Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Sun, 14 May 2017 14:31:11 +0100 Subject: [PATCH 01/13] bpo-30362 Add list options to launcher. --- PC/launcher.c | 114 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 32 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 25fa4ca9c211b9..0517fa52938984 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1371,6 +1371,83 @@ get_version_info(wchar_t * version_text, size_t size) } } +static void +show_help_text(wchar_t ** argv) +{ + wchar_t version_text [MAX_PATH]; +#if defined(_M_X64) + BOOL canDo64bit = TRUE; +#else + /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys. */ + BOOL canDo64bit = FALSE; + IsWow64Process(GetCurrentProcess(), &canDo64bit); +#endif + + get_version_info(version_text, MAX_PATH); + fwprintf(stdout, L"\ +Python Launcher for Windows Version %ls\n\n", version_text); + fwprintf(stdout, L"\ +usage:\n\ +%ls [launcher-args] [python-args] script [script-args]\n\n", argv[0]); + fputws(L"\ +Launcher arguments:\n\n\ +-2 : Launch the latest Python 2.x version\n\ +-3 : Launch the latest Python 3.x version\n\ +-X.Y : Launch the specified Python version\n", stdout); + if (canDo64bit) { + fputws(L"\ + The above all default to 64 bit if a matching 64 bit python is present.\n\ +-X.Y-32: Launch the specified 32bit Python version\n\ +-X-32 : Launch the latest 32bit Python X version\n\ +-X.Y-64: Launch the specified 64bit Python version\n\ +-X-64 : Launch the latest 64bit Python X version", stdout); + } + fputws(L"\n\nThe following help text is from Python:\n\n", stdout); + fflush(stdout); +} + +static void +show_python_list(wchar_t ** argv) +{ + INSTALLED_PYTHON * result = NULL; + INSTALLED_PYTHON * ip = installed_pythons; + size_t i = 0; + wchar_t *fmt = L"\n -%s-%d"; + + /* + * Output informational messages to stderr to keep output + * clean for use in pipes, etc. + */ + fwprintf(stderr, + L"Installed Pythons found by %s Launcher for Windows", argv[0]); + if (!wcscmp(argv[1], L"-L") || !_wcsicmp(argv[1], L"--long-list")) + { + fmt = L"\n -%s-%d\t%s"; + fwprintf(stderr, L" with Paths"); + } + + if (num_installed_pythons == 0) + locate_all_pythons(); + + if (num_installed_pythons == 0) + fwprintf(stderr, L"\nNo Installed Pythons Found!"); + else + { + for (i = 0; i < num_installed_pythons; i++, ip++) { + fwprintf(stdout, fmt, ip->version, ip->bits, ip->executable); + } + } + + ip = locate_python(L"", FALSE); + if (ip == NULL) + fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); + else + fwprintf(stderr, \ + L"\n\nDefault Python Version %s (%d Bit) from %s\n\n", \ + ip->version, ip->bits, ip->executable); + exit(0); +} + static int process(int argc, wchar_t ** argv) { @@ -1385,7 +1462,6 @@ process(int argc, wchar_t ** argv) DWORD size, attrs; HRESULT hr; wchar_t message[MSGSIZE]; - wchar_t version_text [MAX_PATH]; void * version_data; VS_FIXEDFILEINFO * file_info; UINT block_size; @@ -1550,37 +1626,11 @@ installed", &p[1]); error(RC_NO_PYTHON, L"Can't find a default Python."); executable = ip->executable; } - if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) { -#if defined(_M_X64) - BOOL canDo64bit = TRUE; -#else - /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys. */ - BOOL canDo64bit = FALSE; - IsWow64Process(GetCurrentProcess(), &canDo64bit); -#endif - - get_version_info(version_text, MAX_PATH); - fwprintf(stdout, L"\ -Python Launcher for Windows Version %ls\n\n", version_text); - fwprintf(stdout, L"\ -usage:\n\ -%ls [launcher-args] [python-args] script [script-args]\n\n", argv[0]); - fputws(L"\ -Launcher arguments:\n\n\ --2 : Launch the latest Python 2.x version\n\ --3 : Launch the latest Python 3.x version\n\ --X.Y : Launch the specified Python version\n", stdout); - if (canDo64bit) { - fputws(L"\ - The above all default to 64 bit if a matching 64 bit python is present.\n\ --X.Y-32: Launch the specified 32bit Python version\n\ --X-32 : Launch the latest 32bit Python X version\n\ --X.Y-64: Launch the specified 64bit Python version\n\ --X-64 : Launch the latest 64bit Python X version", stdout); - } - fputws(L"\n\nThe following help text is from Python:\n\n", stdout); - fflush(stdout); - } + if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) + show_help_text(argv); + if ((argc == 2) && (!_wcsicmp(p, L"-l") || !_wcsicmp(p, L"--list") ||\ + !_wcsicmp(p, L"--long-list"))) + show_python_list(argv); } invoke_child(executable, NULL, command); return rc; From d54176ab727c620fc75d048c0e4898d7b36cf56e Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Sun, 14 May 2017 14:45:00 +0100 Subject: [PATCH 02/13] bpo-30362 Add list options to help message. --- PC/launcher.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 0517fa52938984..6302bc32d16888 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1376,34 +1376,36 @@ show_help_text(wchar_t ** argv) { wchar_t version_text [MAX_PATH]; #if defined(_M_X64) - BOOL canDo64bit = TRUE; + BOOL canDo64bit = TRUE; #else /* If we are a 32bit process on a 64bit Windows, first hit the 64bit keys. */ - BOOL canDo64bit = FALSE; - IsWow64Process(GetCurrentProcess(), &canDo64bit); + BOOL canDo64bit = FALSE; + IsWow64Process(GetCurrentProcess(), &canDo64bit); #endif - get_version_info(version_text, MAX_PATH); - fwprintf(stdout, L"\ + get_version_info(version_text, MAX_PATH); + fwprintf(stdout, L"\ Python Launcher for Windows Version %ls\n\n", version_text); - fwprintf(stdout, L"\ + fwprintf(stdout, L"\ usage:\n\ %ls [launcher-args] [python-args] script [script-args]\n\n", argv[0]); - fputws(L"\ + fputws(L"\ Launcher arguments:\n\n\ -2 : Launch the latest Python 2.x version\n\ -3 : Launch the latest Python 3.x version\n\ -X.Y : Launch the specified Python version\n", stdout); - if (canDo64bit) { - fputws(L"\ + if (canDo64bit) { + fputws(L"\ The above all default to 64 bit if a matching 64 bit python is present.\n\ -X.Y-32: Launch the specified 32bit Python version\n\ -X-32 : Launch the latest 32bit Python X version\n\ -X.Y-64: Launch the specified 64bit Python version\n\ -X-64 : Launch the latest 64bit Python X version", stdout); - } - fputws(L"\n\nThe following help text is from Python:\n\n", stdout); - fflush(stdout); + } + fputws(L"\n-l/--list : List the available pythons", stdout); + fputws(L"\n-L/--long-list : List with paths", stdout); + fputws(L"\n\nThe following help text is from Python:\n\n", stdout); + fflush(stdout); } static void From 56e55ce7fc3200572effdfae3a236908b480fb5d Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Wed, 17 May 2017 08:05:24 +0100 Subject: [PATCH 03/13] To avoid possible later conflict with python replaced flags with --launcher-list and --launcher-list-paths --- PC/launcher.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 6302bc32d16888..82988d7cc62baf 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1402,8 +1402,8 @@ Launcher arguments:\n\n\ -X.Y-64: Launch the specified 64bit Python version\n\ -X-64 : Launch the latest 64bit Python X version", stdout); } - fputws(L"\n-l/--list : List the available pythons", stdout); - fputws(L"\n-L/--long-list : List with paths", stdout); + fputws(L"\n--launcher-list : List the available pythons", stdout); + fputws(L"\n--launcher-list-paths : List with paths", stdout); fputws(L"\n\nThe following help text is from Python:\n\n", stdout); fflush(stdout); } @@ -1422,7 +1422,7 @@ show_python_list(wchar_t ** argv) */ fwprintf(stderr, L"Installed Pythons found by %s Launcher for Windows", argv[0]); - if (!wcscmp(argv[1], L"-L") || !_wcsicmp(argv[1], L"--long-list")) + if (!_wcsicmp(argv[1], L"--launcher-list-paths")) { fmt = L"\n -%s-%d\t%s"; fwprintf(stderr, L" with Paths"); @@ -1630,8 +1630,8 @@ installed", &p[1]); } if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) show_help_text(argv); - if ((argc == 2) && (!_wcsicmp(p, L"-l") || !_wcsicmp(p, L"--list") ||\ - !_wcsicmp(p, L"--long-list"))) + if ((argc == 2) && (!_wcsicmp(p, L"--launcher-list") ||\ + !_wcsicmp(p, L"--launcher-list-paths"))) show_python_list(argv); } invoke_child(executable, NULL, command); From 62c4c052757329b114a924a9d1792d8a5b9218ca Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Sat, 20 May 2017 07:53:50 +0100 Subject: [PATCH 04/13] bpo-30362 Changed flag to -0 as suggested on review. --- PC/launcher.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 82988d7cc62baf..80567460c25739 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1402,8 +1402,7 @@ Launcher arguments:\n\n\ -X.Y-64: Launch the specified 64bit Python version\n\ -X-64 : Launch the latest 64bit Python X version", stdout); } - fputws(L"\n--launcher-list : List the available pythons", stdout); - fputws(L"\n--launcher-list-paths : List with paths", stdout); + fputws(L"\n-0 : List the available pythons", stdout); fputws(L"\n\nThe following help text is from Python:\n\n", stdout); fflush(stdout); } @@ -1414,7 +1413,7 @@ show_python_list(wchar_t ** argv) INSTALLED_PYTHON * result = NULL; INSTALLED_PYTHON * ip = installed_pythons; size_t i = 0; - wchar_t *fmt = L"\n -%s-%d"; + wchar_t *fmt = L"\n -%ls-%d\t%ls"; /* * Output informational messages to stderr to keep output @@ -1422,11 +1421,6 @@ show_python_list(wchar_t ** argv) */ fwprintf(stderr, L"Installed Pythons found by %s Launcher for Windows", argv[0]); - if (!_wcsicmp(argv[1], L"--launcher-list-paths")) - { - fmt = L"\n -%s-%d\t%s"; - fwprintf(stderr, L" with Paths"); - } if (num_installed_pythons == 0) locate_all_pythons(); @@ -1445,7 +1439,7 @@ show_python_list(wchar_t ** argv) fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); else fwprintf(stderr, \ - L"\n\nDefault Python Version %s (%d Bit) from %s\n\n", \ + L"\n\nDefault Python Version %ls (%d Bit) from %ls\n\n", \ ip->version, ip->bits, ip->executable); exit(0); } @@ -1594,12 +1588,14 @@ process(int argc, wchar_t ** argv) else { p = argv[1]; plen = wcslen(p); + if ((argc == 2) && !_wcsicmp(p, L"-0")) + show_python_list(argv); /* Check for -0 FIRST */ valid = (*p == L'-') && validate_version(&p[1]); if (valid) { ip = locate_python(&p[1], FALSE); if (ip == NULL) error(RC_NO_PYTHON, L"Requested Python version (%ls) not \ -installed", &p[1]); +installed, use -0 for available pythons", &p[1]); executable = ip->executable; command += wcslen(p); command = skip_whitespace(command); @@ -1618,6 +1614,8 @@ installed", &p[1]); #endif if (!valid) { + if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) + show_help_text(argv); /* Look for an active virtualenv */ executable = find_python_by_venv(); @@ -1628,11 +1626,6 @@ installed", &p[1]); error(RC_NO_PYTHON, L"Can't find a default Python."); executable = ip->executable; } - if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) - show_help_text(argv); - if ((argc == 2) && (!_wcsicmp(p, L"--launcher-list") ||\ - !_wcsicmp(p, L"--launcher-list-paths"))) - show_python_list(argv); } invoke_child(executable, NULL, command); return rc; From e966883f7cf6ade807b129c95984697fac7aec93 Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Sun, 21 May 2017 06:58:47 +0100 Subject: [PATCH 05/13] bpo-30362: Modified to default to not path for -0, -0p to dispaly path and append * to default --- PC/launcher.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 80567460c25739..fbe91c53af57f2 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1403,6 +1403,7 @@ Launcher arguments:\n\n\ -X-64 : Launch the latest 64bit Python X version", stdout); } fputws(L"\n-0 : List the available pythons", stdout); + fputws(L"\n-0p : List with paths", stdout); fputws(L"\n\nThe following help text is from Python:\n\n", stdout); fflush(stdout); } @@ -1410,10 +1411,16 @@ Launcher arguments:\n\n\ static void show_python_list(wchar_t ** argv) { + /* + * Display options -0 + */ INSTALLED_PYTHON * result = NULL; INSTALLED_PYTHON * ip = installed_pythons; + INSTALLED_PYTHON * defpy = locate_python(L"", FALSE); size_t i = 0; - wchar_t *fmt = L"\n -%ls-%d\t%ls"; + wchar_t *p = argv[1]; + wchar_t *fmt = L"\n -%ls-%d"; /* print VER-BITS */ + wchar_t *defind = L" *"; /* Default indicator */ /* * Output informational messages to stderr to keep output @@ -1421,6 +1428,8 @@ show_python_list(wchar_t ** argv) */ fwprintf(stderr, L"Installed Pythons found by %s Launcher for Windows", argv[0]); + if (!_wcsicmp(p, L"-0p")) /* Show path? */ + fmt = L"\n -%ls-%d\t%ls"; /* print VER-BITS path */ if (num_installed_pythons == 0) locate_all_pythons(); @@ -1431,16 +1440,16 @@ show_python_list(wchar_t ** argv) { for (i = 0; i < num_installed_pythons; i++, ip++) { fwprintf(stdout, fmt, ip->version, ip->bits, ip->executable); + /* If there is a default indicate it */ + if ((defpy != NULL) && !_wcsicmp(ip->executable, defpy->executable)) + fwprintf(stdout, defind); } } ip = locate_python(L"", FALSE); - if (ip == NULL) + if ((defpy == NULL) && (num_installed_pythons > 0)) + /* We have pythons but none is the default */ fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); - else - fwprintf(stderr, \ - L"\n\nDefault Python Version %ls (%d Bit) from %ls\n\n", \ - ip->version, ip->bits, ip->executable); exit(0); } @@ -1453,6 +1462,7 @@ process(int argc, wchar_t ** argv) wchar_t * p; int rc = 0; size_t plen; + size_t slen; INSTALLED_PYTHON * ip; BOOL valid; DWORD size, attrs; @@ -1588,8 +1598,11 @@ process(int argc, wchar_t ** argv) else { p = argv[1]; plen = wcslen(p); - if ((argc == 2) && !_wcsicmp(p, L"-0")) - show_python_list(argv); /* Check for -0 FIRST */ + if (argc == 2) { + slen = wcslen(L"-0"); + if(!wcsncmp(p, L"-0", slen)) /* Starts with -0 */ + show_python_list(argv); /* Check for -0 FIRST */ + } valid = (*p == L'-') && validate_version(&p[1]); if (valid) { ip = locate_python(&p[1], FALSE); From 60dbcae383a7b2c3a85069fff27c49beb076d4ff Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Sun, 21 May 2017 07:46:27 +0100 Subject: [PATCH 06/13] bpo-30362: Modified to display list on required version not found. --- PC/launcher.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PC/launcher.c b/PC/launcher.c index fbe91c53af57f2..85337a2502f245 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1607,8 +1607,13 @@ process(int argc, wchar_t ** argv) if (valid) { ip = locate_python(&p[1], FALSE); if (ip == NULL) + { + fwprintf(stdout, \ + L"Python %ls not found!\n", &p[1]); + show_python_list(argv); error(RC_NO_PYTHON, L"Requested Python version (%ls) not \ installed, use -0 for available pythons", &p[1]); + } executable = ip->executable; command += wcslen(p); command = skip_whitespace(command); From a323cac8bd62d1422e4bfa93dd96b4d672545d35 Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Wed, 24 May 2017 14:54:57 +0100 Subject: [PATCH 07/13] bpo-30362 add --list and --list-paths added back in following review by paul.moore --- PC/launcher.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 85337a2502f245..427285688c99a0 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1402,8 +1402,8 @@ Launcher arguments:\n\n\ -X.Y-64: Launch the specified 64bit Python version\n\ -X-64 : Launch the latest 64bit Python X version", stdout); } - fputws(L"\n-0 : List the available pythons", stdout); - fputws(L"\n-0p : List with paths", stdout); + fputws(L"\n-0 --list : List the available pythons", stdout); + fputws(L"\n-0p --list-paths : List with paths", stdout); fputws(L"\n\nThe following help text is from Python:\n\n", stdout); fflush(stdout); } @@ -1428,7 +1428,7 @@ show_python_list(wchar_t ** argv) */ fwprintf(stderr, L"Installed Pythons found by %s Launcher for Windows", argv[0]); - if (!_wcsicmp(p, L"-0p")) /* Show path? */ + if (!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")) /* Show path? */ fmt = L"\n -%ls-%d\t%ls"; /* print VER-BITS path */ if (num_installed_pythons == 0) @@ -1602,6 +1602,9 @@ process(int argc, wchar_t ** argv) slen = wcslen(L"-0"); if(!wcsncmp(p, L"-0", slen)) /* Starts with -0 */ show_python_list(argv); /* Check for -0 FIRST */ + slen = wcslen(L"-list"); + if(!wcsncmp(p, L"-list", slen)) /* Starts with -0 */ + show_python_list(argv); /* Check for -0 FIRST */ } valid = (*p == L'-') && validate_version(&p[1]); if (valid) { From 140e6a18dd5d4a5f708205c40cfa7a55569a8038 Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Tue, 27 Jun 2017 07:31:20 +0100 Subject: [PATCH 08/13] bpo-30362 Cleaner handing of -0 & -0p by not calling exit directly per review by @zooba --- PC/launcher.c | 53 ++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/PC/launcher.c b/PC/launcher.c index 427285688c99a0..d2277f47c5334b 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1408,14 +1408,14 @@ Launcher arguments:\n\n\ fflush(stdout); } -static void +static BOOL show_python_list(wchar_t ** argv) { /* * Display options -0 */ INSTALLED_PYTHON * result = NULL; - INSTALLED_PYTHON * ip = installed_pythons; + INSTALLED_PYTHON * ip = installed_pythons; /* List of installed pythons */ INSTALLED_PYTHON * defpy = locate_python(L"", FALSE); size_t i = 0; wchar_t *p = argv[1]; @@ -1431,10 +1431,10 @@ show_python_list(wchar_t ** argv) if (!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")) /* Show path? */ fmt = L"\n -%ls-%d\t%ls"; /* print VER-BITS path */ - if (num_installed_pythons == 0) - locate_all_pythons(); + if (num_installed_pythons == 0) /* We have somehow got here without searching for pythons */ + locate_all_pythons(); /* Find them, Populates installed_pythons */ - if (num_installed_pythons == 0) + if (num_installed_pythons == 0) /* No pythons found */ fwprintf(stderr, L"\nNo Installed Pythons Found!"); else { @@ -1442,15 +1442,15 @@ show_python_list(wchar_t ** argv) fwprintf(stdout, fmt, ip->version, ip->bits, ip->executable); /* If there is a default indicate it */ if ((defpy != NULL) && !_wcsicmp(ip->executable, defpy->executable)) - fwprintf(stdout, defind); + fwprintf(stderr, defind); } } - ip = locate_python(L"", FALSE); + /*ip = locate_python(L"", FALSE);*/ if ((defpy == NULL) && (num_installed_pythons > 0)) /* We have pythons but none is the default */ fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); - exit(0); + return(FALSE); /* If this has been called we cannot continue */ } static int @@ -1601,19 +1601,16 @@ process(int argc, wchar_t ** argv) if (argc == 2) { slen = wcslen(L"-0"); if(!wcsncmp(p, L"-0", slen)) /* Starts with -0 */ - show_python_list(argv); /* Check for -0 FIRST */ - slen = wcslen(L"-list"); - if(!wcsncmp(p, L"-list", slen)) /* Starts with -0 */ - show_python_list(argv); /* Check for -0 FIRST */ + valid = show_python_list(argv); /* Check for -0 FIRST */ } - valid = (*p == L'-') && validate_version(&p[1]); + valid = valid && (*p == L'-') && validate_version(&p[1]); if (valid) { ip = locate_python(&p[1], FALSE); if (ip == NULL) { fwprintf(stdout, \ L"Python %ls not found!\n", &p[1]); - show_python_list(argv); + valid = show_python_list(argv); error(RC_NO_PYTHON, L"Requested Python version (%ls) not \ installed, use -0 for available pythons", &p[1]); } @@ -1637,18 +1634,26 @@ installed, use -0 for available pythons", &p[1]); if (!valid) { if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help"))) show_help_text(argv); - /* Look for an active virtualenv */ - executable = find_python_by_venv(); - - /* If we didn't find one, look for the default Python */ - if (executable == NULL) { - ip = locate_python(L"", FALSE); - if (ip == NULL) - error(RC_NO_PYTHON, L"Can't find a default Python."); - executable = ip->executable; + if ((argc == 2) && (!_wcsicmp(p, L"-0") || !_wcsicmp(p, L"-0p"))) + executable = NULL; /* Info call only */ + else + { + /* Look for an active virtualenv */ + executable = find_python_by_venv(); + + /* If we didn't find one, look for the default Python */ + if (executable == NULL) { + ip = locate_python(L"", FALSE); + if (ip == NULL) + error(RC_NO_PYTHON, L"Can't find a default Python."); + executable = ip->executable; + } } } - invoke_child(executable, NULL, command); + if (executable != NULL) + invoke_child(executable, NULL, command); + else + rc = RC_NO_PYTHON; return rc; } From 77714cec53411905888bd9796327030b317cda7e Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Wed, 28 Jun 2017 04:15:23 +0100 Subject: [PATCH 09/13] bpo-30362: Tidy up and add news & what's new Removed commented out line of code in PC/launcher.c. Added the results of using blurb to add details of bpo-30362 & bpo-30291. Updated Doc/whatsnew/3.7.rst to add a Windows only section covering both tickets. --- Doc/whatsnew/3.7.rst | 13 +++++++++++++ Misc/NEWS.d/next/C API/README.rst | 1 + Misc/NEWS.d/next/Core and Builtins/README.rst | 1 + Misc/NEWS.d/next/Documentation/README.rst | 1 + Misc/NEWS.d/next/IDLE/README.rst | 1 + Misc/NEWS.d/next/Library/README.rst | 1 + Misc/NEWS.d/next/Security/README.rst | 1 + Misc/NEWS.d/next/Tests/README.rst | 1 + Misc/NEWS.d/next/Tools-Demos/README.rst | 1 + .../2017-06-28-03-08-22.bpo-30362.XxeVMB.rst | 8 ++++++++ .../2017-06-28-03-20-48.bpo-30291.zBpOl6.rst | 8 ++++++++ Misc/NEWS.d/next/Windows/README.rst | 1 + Misc/NEWS.d/next/macOS/README.rst | 1 + PC/launcher.c | 3 ++- 14 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/C API/README.rst create mode 100644 Misc/NEWS.d/next/Core and Builtins/README.rst create mode 100644 Misc/NEWS.d/next/Documentation/README.rst create mode 100644 Misc/NEWS.d/next/IDLE/README.rst create mode 100644 Misc/NEWS.d/next/Library/README.rst create mode 100644 Misc/NEWS.d/next/Security/README.rst create mode 100644 Misc/NEWS.d/next/Tests/README.rst create mode 100644 Misc/NEWS.d/next/Tools-Demos/README.rst create mode 100644 Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst create mode 100644 Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst create mode 100644 Misc/NEWS.d/next/Windows/README.rst create mode 100644 Misc/NEWS.d/next/macOS/README.rst diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index 3a001d7b4482ad..1314bcc6edf6e1 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -275,6 +275,19 @@ Changes in the C API :c:type:`unsigned long`. (Contributed by Serhiy Storchaka in :issue:`6532`.) +Windows Only +------------ +- The python launcher, (py.exe), can accept 32 & 64 bit specifiers **without** + having to specify a minor version as well. So ``py -3-32`` and ``py -3-64`` + become valid as well as ``py -3.7-32``, also the -*m*-64 and -*m.n*-64 forms + are now accepted to force 64 bit python even if 32 bit would have otherwise + been used. If the specified version is not available py.exe will error exit. + (Contributed by Steve Barnes in :issue:`30291`.) +- The launcher can be run as "py -0" to produce a list of the installed pythons, + *with default marked with an asterix*. Running "py -0p" will include the paths. + If py is run with a version specifier that cannot be matched it will also print + the *short form* list of available specifiers. + (Contributed by Steve Barnes in :issue:`30362`.) Removed ======= diff --git a/Misc/NEWS.d/next/C API/README.rst b/Misc/NEWS.d/next/C API/README.rst new file mode 100644 index 00000000000000..5a04f76f47b67e --- /dev/null +++ b/Misc/NEWS.d/next/C API/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *C API* section in this directory. diff --git a/Misc/NEWS.d/next/Core and Builtins/README.rst b/Misc/NEWS.d/next/Core and Builtins/README.rst new file mode 100644 index 00000000000000..52b8c3e6263163 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Core and Builtins* section in this directory. diff --git a/Misc/NEWS.d/next/Documentation/README.rst b/Misc/NEWS.d/next/Documentation/README.rst new file mode 100644 index 00000000000000..405f0ac01a7202 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Documentation* section in this directory. diff --git a/Misc/NEWS.d/next/IDLE/README.rst b/Misc/NEWS.d/next/IDLE/README.rst new file mode 100644 index 00000000000000..5475f7b42050cd --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *IDLE* section in this directory. diff --git a/Misc/NEWS.d/next/Library/README.rst b/Misc/NEWS.d/next/Library/README.rst new file mode 100644 index 00000000000000..6d2d30eca0fd05 --- /dev/null +++ b/Misc/NEWS.d/next/Library/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Library* section in this directory. diff --git a/Misc/NEWS.d/next/Security/README.rst b/Misc/NEWS.d/next/Security/README.rst new file mode 100644 index 00000000000000..84c1a3a6ed7a07 --- /dev/null +++ b/Misc/NEWS.d/next/Security/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Security* section in this directory. diff --git a/Misc/NEWS.d/next/Tests/README.rst b/Misc/NEWS.d/next/Tests/README.rst new file mode 100644 index 00000000000000..d2e50e43d84790 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Tests* section in this directory. diff --git a/Misc/NEWS.d/next/Tools-Demos/README.rst b/Misc/NEWS.d/next/Tools-Demos/README.rst new file mode 100644 index 00000000000000..357f82862cb51a --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Tools/Demos* section in this directory. diff --git a/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst b/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst new file mode 100644 index 00000000000000..bf6286916dd9ae --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst @@ -0,0 +1,8 @@ +The python launcher, py.exe, has gained a -0 option and a -0p option. These +options _when used on their own_ will list the currently avaialbe python +versions on the host machine, with the -0p also listing the paths of each. +The current default python is indicated by an asterix on the same line. + +Note that the versions are in the format accepted by py.exe and that the +stdout output when redirected to a file will only consist of these lines, +the remaining output is printed to stderr. Contributed by Steve Barnes. diff --git a/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst b/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst new file mode 100644 index 00000000000000..6ed12945d3fc9f --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst @@ -0,0 +1,8 @@ +Changes to the windows launcher, (py.exe), to allow short, bit length +specific, invocation. _Previously, if you wished to launch a specific bit +length python, you had to specify both major and minor versions of python +and you could not force 64 bit_. With this change you can call py -2-32 or +py -3-32 to invoke the latest 32 bit python 2 & 3 installed on the machine +and you can now also call py -3-64 to specifically invoke 64 bit with an +error if it is not present. You can still specify the minor version but you +don't have to. Contributed by Steve (Gadget) Barnes. diff --git a/Misc/NEWS.d/next/Windows/README.rst b/Misc/NEWS.d/next/Windows/README.rst new file mode 100644 index 00000000000000..1e65de35f0ad97 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *Windows* section in this directory. diff --git a/Misc/NEWS.d/next/macOS/README.rst b/Misc/NEWS.d/next/macOS/README.rst new file mode 100644 index 00000000000000..a3adb59b62631e --- /dev/null +++ b/Misc/NEWS.d/next/macOS/README.rst @@ -0,0 +1 @@ +Put news entry ``blurb`` files for the *macOS* section in this directory. diff --git a/PC/launcher.c b/PC/launcher.c index d2277f47c5334b..0733df7563f121 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1446,10 +1446,11 @@ show_python_list(wchar_t ** argv) } } - /*ip = locate_python(L"", FALSE);*/ if ((defpy == NULL) && (num_installed_pythons > 0)) /* We have pythons but none is the default */ fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n"); + else + fwprintf(stderr, L"\n\n"); /* End with a blank line */ return(FALSE); /* If this has been called we cannot continue */ } From 8493826a7bf227a572ca60415061b3cac234e874 Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Wed, 28 Jun 2017 04:20:49 +0100 Subject: [PATCH 10/13] bpo-30362 Resolve conflict in Doc/whatsnew/3.7.rst --- Doc/whatsnew/3.7.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index 1314bcc6edf6e1..133fc4aa19ea57 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -275,6 +275,10 @@ Changes in the C API :c:type:`unsigned long`. (Contributed by Serhiy Storchaka in :issue:`6532`.) +- :c:func:`PyUnicode_AsWideCharString` now raises a :exc:`ValueError` if the + second argument is *NULL* and the :c:type:`wchar_t*` string contains null + characters. (Contributed by Serhiy Storchaka in :issue:`30708`.) + Windows Only ------------ - The python launcher, (py.exe), can accept 32 & 64 bit specifiers **without** @@ -283,6 +287,7 @@ Windows Only are now accepted to force 64 bit python even if 32 bit would have otherwise been used. If the specified version is not available py.exe will error exit. (Contributed by Steve Barnes in :issue:`30291`.) + - The launcher can be run as "py -0" to produce a list of the installed pythons, *with default marked with an asterix*. Running "py -0p" will include the paths. If py is run with a version specifier that cannot be matched it will also print From eeecbee255ac49d04d97c640ab7c59551ded65ee Mon Sep 17 00:00:00 2001 From: Steve Barnes Date: Wed, 28 Jun 2017 05:35:07 +0100 Subject: [PATCH 11/13] bpo-30362:Address Whitespace Issue in Doc\whatsnew\3.7.rst --- Doc/whatsnew/3.7.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index c650c0115bdd0f..c75d7692a4d8be 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -371,9 +371,9 @@ Windows Only having to specify a minor version as well. So ``py -3-32`` and ``py -3-64`` become valid as well as ``py -3.7-32``, also the -*m*-64 and -*m.n*-64 forms are now accepted to force 64 bit python even if 32 bit would have otherwise - been used. If the specified version is not available py.exe will error exit. + been used. If the specified version is not available py.exe will error exit. (Contributed by Steve Barnes in :issue:`30291`.) - + - The launcher can be run as "py -0" to produce a list of the installed pythons, *with default marked with an asterix*. Running "py -0p" will include the paths. If py is run with a version specifier that cannot be matched it will also print From ebd350df6251d6ab7cd5f933ae9b5f133d28714f Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 28 Jun 2017 11:54:56 -0700 Subject: [PATCH 12/13] Shorten NEWS message for bpo-30362 --- .../Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst b/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst index bf6286916dd9ae..fb24ec541f3c03 100644 --- a/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst +++ b/Misc/NEWS.d/next/Windows/2017-06-28-03-08-22.bpo-30362.XxeVMB.rst @@ -1,8 +1 @@ -The python launcher, py.exe, has gained a -0 option and a -0p option. These -options _when used on their own_ will list the currently avaialbe python -versions on the host machine, with the -0p also listing the paths of each. -The current default python is indicated by an asterix on the same line. - -Note that the versions are in the format accepted by py.exe and that the -stdout output when redirected to a file will only consist of these lines, -the remaining output is printed to stderr. Contributed by Steve Barnes. +Adds list options (-0, -0p) to py.exe launcher. Contributed by Steve Barnes. From 93f7584079f94159dabfd10ac875ca572e8f9c52 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 28 Jun 2017 11:56:04 -0700 Subject: [PATCH 13/13] Shorten NEWS item for bpo-30291 --- .../Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst b/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst index 6ed12945d3fc9f..2869823326d016 100644 --- a/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst +++ b/Misc/NEWS.d/next/Windows/2017-06-28-03-20-48.bpo-30291.zBpOl6.rst @@ -1,8 +1,2 @@ -Changes to the windows launcher, (py.exe), to allow short, bit length -specific, invocation. _Previously, if you wished to launch a specific bit -length python, you had to specify both major and minor versions of python -and you could not force 64 bit_. With this change you can call py -2-32 or -py -3-32 to invoke the latest 32 bit python 2 & 3 installed on the machine -and you can now also call py -3-64 to specifically invoke 64 bit with an -error if it is not present. You can still specify the minor version but you -don't have to. Contributed by Steve (Gadget) Barnes. +Allow requiring 64-bit interpreters from py.exe using -64 suffix. Contributed +by Steve (Gadget) Barnes.