Skip to content

Instantly share code, notes, and snippets.

@ojii
Last active December 26, 2018 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ojii/f67391526080b26e4866eb770e0df30a to your computer and use it in GitHub Desktop.
Save ojii/f67391526080b26e4866eb770e0df30a to your computer and use it in GitHub Desktop.
Make `python -c ...` print the result
$ ./python.exe -c '2+3'
5
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