Last active
December 26, 2018 06:12
-
-
Save ojii/f67391526080b26e4866eb770e0df30a to your computer and use it in GitHub Desktop.
Make `python -c ...` print the result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./python.exe -c '2+3' | |
5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Python/pythonrun.c b/Python/pythonrun.c | |
index 9b6371d9c0..308066d7b1 100644 | |
--- a/Python/pythonrun.c | |
+++ b/Python/pythonrun.c | |
@@ -454,7 +454,7 @@ PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags) | |
if (m == NULL) | |
return -1; | |
d = PyModule_GetDict(m); | |
- v = PyRun_StringFlags(command, Py_file_input, d, d, flags); | |
+ v = PyRun_StringFlags(command, Py_single_input, d, d, flags); | |
if (v == NULL) { | |
PyErr_Print(); | |
return -1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment