3if sys.version_info[0] < 3:
4 import __builtin__
as builtins
22 if "libedit" in readline.__doc__:
23 readline.parse_and_bind(
"bind ^I rl_complete")
25 readline.parse_and_bind(
"tab: complete")
30g_run_one_line_str =
None
39 hw = struct.unpack(
"hh", fcntl.ioctl(fd, termios.TIOCGWINSZ,
"1234"))
51 if line
in (
"exit",
"quit"):
62 sys.stdout.write(prompt)
64 line = sys.stdin.readline()
75 fd = sys.stdin.fileno()
81 old = termios.tcgetattr(fd)
82 if old[3] & termios.ECHO:
84 new = termios.tcgetattr(fd)
85 new[3] = new[3] & ~termios.ECHO
87 termios.tcsetattr(fd, termios.TCSADRAIN, new)
90 banner=
"Python Interactive Interpreter. To exit, type 'quit()', 'exit()'.",
91 readfunc=readfunc_stdio,
95 termios.tcsetattr(fd, termios.TCSADRAIN, old)
101 banner=
"Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.",
102 readfunc=readfunc_stdio,
108 banner=
"Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.",
114 except SystemExit
as e:
116 print(
"Script exited with code %s" % e.code)
120 global g_run_one_line_str
123 repl = code.InteractiveConsole(local_dict)
129 repl.runsource(input_string)
130 elif g_run_one_line_str:
131 repl.runsource(g_run_one_line_str)
134 except SystemExit
as e:
136 print(
"Script exited with code %s" % e.code)
def run_one_line(local_dict, input_string)
def readfunc_stdio(prompt)
def run_python_interpreter(local_dict)
def get_terminal_size(fd)
def strip_and_check_exit(line)