Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 443a65d

Browse filesBrowse files
committed
Fix weird argument processing bug
1 parent b61f4fe commit 443a65d
Copy full SHA for 443a65d

File tree

1 file changed

+15
-6
lines changed
Filter options

1 file changed

+15
-6
lines changed

‎src/lib.rs

Copy file name to clipboardExpand all lines: src/lib.rs
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,29 @@ fn create_settings(matches: &ArgMatches) -> PySettings {
413413
settings.warnopts.extend(warnings.map(ToOwned::to_owned));
414414
}
415415

416-
let argv = if let Some(script) = matches.values_of("script") {
417-
script.map(ToOwned::to_owned).collect()
416+
// script having values even though -c/-m was passed would means that it was something like -mmodule foo bar
417+
let weird_script_args = || {
418+
matches
419+
.values_of("script")
420+
.into_iter()
421+
.flat_map(|script_args| script_args.map(ToOwned::to_owned))
422+
};
423+
let argv = if let Some(cmd) = matches.values_of("c") {
424+
std::iter::once("-c".to_owned())
425+
.chain(cmd.skip(1).map(ToOwned::to_owned))
426+
.chain(weird_script_args())
427+
.collect()
418428
} else if let Some(module) = matches.values_of("m") {
419429
std::iter::once("PLACEHOLDER".to_owned())
420430
.chain(module.skip(1).map(ToOwned::to_owned))
431+
.chain(weird_script_args())
421432
.collect()
422433
} else if let Some(get_pip_args) = matches.values_of("install_pip") {
423434
std::iter::once("get-pip.py".to_owned())
424435
.chain(get_pip_args.map(ToOwned::to_owned))
425436
.collect()
426-
} else if let Some(cmd) = matches.values_of("c") {
427-
std::iter::once("-c".to_owned())
428-
.chain(cmd.skip(1).map(ToOwned::to_owned))
429-
.collect()
437+
} else if let Some(script) = matches.values_of("script") {
438+
script.map(ToOwned::to_owned).collect()
430439
} else {
431440
vec!["".to_owned()]
432441
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.