Skip to content

Commit 403343d

Browse files
committed
"""echo "print 'test'" | bpython""" no longer breaks
bpython now checks if stdin is a tty and, if not, executes stdin through a simple interpreter instance and exits. committer: Bob Farrell <robertanthonyfarrell@gmail.com>
1 parent f626f60 commit 403343d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎CHANGELOG‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Menno sent me some patches to fix some stuff:
99
flush_output option added to config to control whether output is flushed to
1010
stdout or not on exit.
1111

12+
Piping something to bpython made it lock up as stdin was not the keyboard -
13+
bpython just executes stdin and exits instead of trying to do something clever.
14+
1215
v0.7.1
1316
======
1417
Added support for a history file, defaults to ~/.pythonhist and 100 lines but

‎bpython/cli.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import shlex
4646
import socket
4747
import pydoc
48-
import cStringIO
48+
from cStringIO import StringIO
4949

5050
# These are used for syntax hilighting.
5151
from pygments import highlight
@@ -1715,7 +1715,13 @@ def main_curses(scr):
17151715

17161716

17171717
def main():
1718+
if not os.isatty(sys.stdin.fileno()):
1719+
interpreter = code.InteractiveInterpreter()
1720+
interpreter.runsource(sys.stdin.read())
1721+
return
1722+
17181723
tb = None
1724+
17191725
try:
17201726
o = curses.wrapper(main_curses)
17211727
except:

0 commit comments

Comments
 (0)