Commit 3a0a81df authored by Kurt B. Kaiser's avatar Kurt B. Kaiser

cvs-py-rel2_1 (Rev 1.29 - 1.33) merge

Merged the following py-cvs revs without conflict:
1.29 Reduce copyright text output at startup
1.30 Delay setting sys.args until Tkinter is fully initialized
1.31 Whitespace normalization
1.32 Turn syntax warning into error when interactive
1.33 Fix warning initialization bug

Note that module is extensively modified wrt py-cvs
parent bc5b8f17
...@@ -27,6 +27,7 @@ import string ...@@ -27,6 +27,7 @@ import string
import getopt import getopt
import re import re
import protocol import protocol
import warnings
import linecache import linecache
from code import InteractiveInterpreter from code import InteractiveInterpreter
...@@ -146,7 +147,7 @@ class ModifiedColorDelegator(ColorDelegator): ...@@ -146,7 +147,7 @@ class ModifiedColorDelegator(ColorDelegator):
"stderr": cconf.getcolor("stderr"), "stderr": cconf.getcolor("stderr"),
"console": cconf.getcolor("console"), "console": cconf.getcolor("console"),
"ERROR": cconf.getcolor("ERROR"), "ERROR": cconf.getcolor("ERROR"),
None: cconf.getcolor("normal"), None: cconf.getcolor("normal"),
}) })
...@@ -178,6 +179,7 @@ class ModifiedInterpreter(InteractiveInterpreter): ...@@ -178,6 +179,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.tkconsole = tkconsole self.tkconsole = tkconsole
locals = sys.modules['__main__'].__dict__ locals = sys.modules['__main__'].__dict__
InteractiveInterpreter.__init__(self, locals=locals) InteractiveInterpreter.__init__(self, locals=locals)
self.save_warnings_filters = None
gid = 0 gid = 0
...@@ -202,7 +204,14 @@ class ModifiedInterpreter(InteractiveInterpreter): ...@@ -202,7 +204,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
# Extend base class to stuff the source in the line cache first # Extend base class to stuff the source in the line cache first
filename = self.stuffsource(source) filename = self.stuffsource(source)
self.more = 0 self.more = 0
return InteractiveInterpreter.runsource(self, source, filename) self.save_warnings_filters = warnings.filters[:]
warnings.filterwarnings(action="error", category=SyntaxWarning)
try:
return InteractiveInterpreter.runsource(self, source, filename)
finally:
if self.save_warnings_filters is not None:
warnings.filters[:] = self.save_warnings_filters
self.save_warnings_filters = None
def stuffsource(self, source): def stuffsource(self, source):
# Stuff source in the filename cache # Stuff source in the filename cache
...@@ -271,6 +280,9 @@ class ModifiedInterpreter(InteractiveInterpreter): ...@@ -271,6 +280,9 @@ class ModifiedInterpreter(InteractiveInterpreter):
def runcode(self, code): def runcode(self, code):
# Override base class method # Override base class method
if self.save_warnings_filters is not None:
warnings.filters[:] = self.save_warnings_filters
self.save_warnings_filters = None
debugger = self.debugger debugger = self.debugger
try: try:
self.tkconsole.beginexecuting() self.tkconsole.beginexecuting()
...@@ -451,10 +463,13 @@ class PyShell(OutputWindow): ...@@ -451,10 +463,13 @@ class PyShell(OutputWindow):
def short_title(self): def short_title(self):
return self.shell_title return self.shell_title
COPYRIGHT = \
'Type "copyright", "credits" or "license" for more information.'
def begin(self): def begin(self):
self.resetoutput() self.resetoutput()
self.write("Python %s on %s\n%s\nIDLE %s -- press F1 for help\n" % self.write("Python %s on %s\n%s\nIDLE %s -- press F1 for help\n" %
(sys.version, sys.platform, sys.copyright, (sys.version, sys.platform, self.COPYRIGHT,
idlever.IDLE_VERSION)) idlever.IDLE_VERSION))
try: try:
sys.ps1 sys.ps1
...@@ -790,12 +805,6 @@ class main: ...@@ -790,12 +805,6 @@ class main:
if noshell: edit=1 if noshell: edit=1
if not edit:
if cmd:
sys.argv = ["-c"] + args
else:
sys.argv = args or [""]
for i in range(len(sys.path)): for i in range(len(sys.path)):
sys.path[i] = os.path.abspath(sys.path[i]) sys.path[i] = os.path.abspath(sys.path[i])
...@@ -813,7 +822,7 @@ class main: ...@@ -813,7 +822,7 @@ class main:
sys.path.insert(0, dir) sys.path.insert(0, dir)
global flist, root global flist, root
root = Tk() root = Tk(className="Idle")
fixwordbreaks(root) fixwordbreaks(root)
root.withdraw() root.withdraw()
flist = PyShellFileList(root) flist = PyShellFileList(root)
...@@ -823,7 +832,12 @@ class main: ...@@ -823,7 +832,12 @@ class main:
flist.open(filename) flist.open(filename)
if not args: if not args:
flist.new() flist.new()
else:
if cmd:
sys.argv = ["-c"] + args
else:
sys.argv = args or [""]
#dbg=OnDemandOutputWindow(flist) #dbg=OnDemandOutputWindow(flist)
#dbg.set_title('Internal IDLE Problem') #dbg.set_title('Internal IDLE Problem')
#sys.stdout = PseudoFile(dbg,['stdout']) #sys.stdout = PseudoFile(dbg,['stdout'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment