Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ae8c63

Browse files
committed
Closes #17028: Allowed Python arguments to be supplied to launcher.
1 parent 64a5562 commit 2ae8c63

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

PC/launcher.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ process(int argc, wchar_t ** argv)
12081208
void * version_data;
12091209
VS_FIXEDFILEINFO * file_info;
12101210
UINT block_size;
1211+
int index;
12111212

12121213
wp = get_env(L"PYLAUNCH_DEBUG");
12131214
if ((wp != NULL) && (*wp != L'\0'))
@@ -1295,13 +1296,6 @@ process(int argc, wchar_t ** argv)
12951296
else {
12961297
p = argv[1];
12971298
plen = wcslen(p);
1298-
if (p[0] != L'-') {
1299-
read_commands();
1300-
maybe_handle_shebang(&argv[1], command);
1301-
}
1302-
/* No file with shebang, or an unrecognised shebang.
1303-
* Is the first arg a special version qualifier?
1304-
*/
13051299
valid = (*p == L'-') && validate_version(&p[1]);
13061300
if (valid) {
13071301
ip = locate_python(&p[1]);
@@ -1311,6 +1305,16 @@ installed", &p[1]);
13111305
command += wcslen(p);
13121306
command = skip_whitespace(command);
13131307
}
1308+
else {
1309+
for (index = 1; index < argc; ++index) {
1310+
if (*argv[index] != L'-')
1311+
break;
1312+
}
1313+
if (index < argc) {
1314+
read_commands();
1315+
maybe_handle_shebang(&argv[index], command);
1316+
}
1317+
}
13141318
}
13151319
if (!valid) {
13161320
ip = locate_python(L"");
@@ -1329,7 +1333,7 @@ installed", &p[1]);
13291333
fwprintf(stdout, L"\
13301334
Python Launcher for Windows Version %s\n\n", version_text);
13311335
fwprintf(stdout, L"\
1332-
usage: %s [ launcher-arguments ] script [ script-arguments ]\n\n", argv[0]);
1336+
usage: %s [ launcher-arguments ] [ python-arguments ] script [ script-arguments ]\n\n", argv[0]);
13331337
fputws(L"\
13341338
Launcher arguments:\n\n\
13351339
-2 : Launch the latest Python 2.x version\n\
@@ -1362,4 +1366,4 @@ int cdecl wmain(int argc, wchar_t ** argv)
13621366
return process(argc, argv);
13631367
}
13641368

1365-
#endif
1369+
#endif

0 commit comments

Comments
 (0)