| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,10 +88,7 @@ def parse(args, extras=None): | |||
| 88 | 88 | raise SystemExit | |
| 89 | 89 | ||
| 90 | 90 | if not (sys.stdin.isatty() and sys.stdout.isatty()): | |
| 91 | - interpreter = code.InteractiveInterpreter() | ||
| 92 | - interpreter.runsource(sys.stdin.read()) | ||
| 93 | - raise SystemExit | ||
| 94 | - | ||
| 91 | + run_stdin(sys.stdin) | ||
| 95 | 92 | path = os.path.expanduser('~/.bpythonrc') | |
| 96 | 93 | # migrating old configuration file | |
| 97 | 94 | if os.path.isfile(path): | |
@@ -113,3 +110,11 @@ def exec_code(interpreter, args): | |||
| 113 | 110 | sys.path.insert(0, os.path.abspath(os.path.dirname(args[0]))) | |
| 114 | 111 | interpreter.runcode(code_obj) | |
| 115 | 112 | sys.argv = old_argv | |
| 113 | + | ||
| 114 | + def run_stdin(stdin): | ||
| 115 | + """ | ||
| 116 | + Run code from a file-like object and exit. | ||
| 117 | + """ | ||
| 118 | + interpreter = code.InteractiveInterpreter() | ||
| 119 | + interpreter.runsource(stdin.read()) | ||
| 120 | + raise SystemExit | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,14 @@ | |||
| 50 | 50 | _COLORS = dict(b='blue', c='cyan', g='green', m='magenta', r='red', | |
| 51 | 51 | w='white', y='yellow', k='black', d='black') | |
| 52 | 52 | ||
| 53 | + def run_stdin(stdin): | ||
| 54 | + """ | ||
| 55 | + Overwrite stdin reader from args as GTK does not supply a stdin/stdout | ||
| 56 | + as a tty. | ||
| 57 | + """ | ||
| 58 | + pass | ||
| 59 | + | ||
| 60 | + bpython.args.run_stdin = run_stdin | ||
| 53 | 61 | ||
| 54 | 62 | class ArgspecFormatter(object): | |
| 55 | 63 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments