mirror of https://github.com/python/cpython
Don't poorly emulate the interactive interpreter, use
code.InteractiveConsole to do a much better job.
This commit is contained in:
parent
a8ef0d1df2
commit
2aabac8276
28
Lib/rexec.py
28
Lib/rexec.py
|
@ -552,25 +552,15 @@ def test():
|
||||||
print "%s: can't open file %s" % (sys.argv[0], `args[0]`)
|
print "%s: can't open file %s" % (sys.argv[0], `args[0]`)
|
||||||
return 1
|
return 1
|
||||||
if fp.isatty():
|
if fp.isatty():
|
||||||
print "*** RESTRICTED *** Python", sys.version
|
import code
|
||||||
print 'Type "help", "copyright", "credits" or "license" ' \
|
interp = code.InteractiveConsole(r.modules['__main__'].__dict__)
|
||||||
'for more information.'
|
try:
|
||||||
|
interp.interact(
|
||||||
while 1:
|
"*** RESTRICTED *** Python %s on %s\n"
|
||||||
try:
|
'Type "help", "copyright", "credits" or "license" '
|
||||||
try:
|
"for more information." % (sys.version, sys.platform))
|
||||||
s = raw_input('>>> ')
|
except SystemExit, n:
|
||||||
except EOFError:
|
return n
|
||||||
print
|
|
||||||
break
|
|
||||||
if s and s[0] != '#':
|
|
||||||
s = s + '\n'
|
|
||||||
c = compile(s, '<stdin>', 'single')
|
|
||||||
r.s_exec(c)
|
|
||||||
except SystemExit, n:
|
|
||||||
return n
|
|
||||||
except:
|
|
||||||
traceback.print_exc()
|
|
||||||
else:
|
else:
|
||||||
text = fp.read()
|
text = fp.read()
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
Loading…
Reference in New Issue