summaryrefslogtreecommitdiffstats
path: root/Lib/rexec.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-06-14 13:48:25 (GMT)
committerGuido van Rossum <guido@python.org>2002-06-14 13:48:25 (GMT)
commit2aabac8276751c6a1a9758a410b8b837354967b8 (patch)
tree91b4ad94abef1628dbdd8512dd8ec1f0bcef6360 /Lib/rexec.py
parenta8ef0d1df29b836920f3fff1da7bf4675302d1f8 (diff)
downloadcpython-2aabac8276751c6a1a9758a410b8b837354967b8.zip
cpython-2aabac8276751c6a1a9758a410b8b837354967b8.tar.gz
cpython-2aabac8276751c6a1a9758a410b8b837354967b8.tar.bz2
Don't poorly emulate the interactive interpreter, use
code.InteractiveConsole to do a much better job.
Diffstat (limited to 'Lib/rexec.py')
-rw-r--r--Lib/rexec.py28
1 files changed, 9 insertions, 19 deletions
diff --git a/Lib/rexec.py b/Lib/rexec.py
index 623cc97..b45fc69 100644
--- a/Lib/rexec.py
+++ b/Lib/rexec.py
@@ -552,25 +552,15 @@ def test():
print "%s: can't open file %s" % (sys.argv[0], `args[0]`)
return 1
if fp.isatty():
- print "*** RESTRICTED *** Python", sys.version
- print 'Type "help", "copyright", "credits" or "license" ' \
- 'for more information.'
-
- while 1:
- try:
- try:
- s = raw_input('>>> ')
- except EOFError:
- 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()
+ import code
+ interp = code.InteractiveConsole(r.modules['__main__'].__dict__)
+ try:
+ interp.interact(
+ "*** RESTRICTED *** Python %s on %s\n"
+ 'Type "help", "copyright", "credits" or "license" '
+ "for more information." % (sys.version, sys.platform))
+ except SystemExit, n:
+ return n
else:
text = fp.read()
fp.close()