mirror of
https://github.com/python/cpython.git
synced 2025-08-12 04:49:01 +00:00
Merged revisions 66922 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66922 | benjamin.peterson | 2008-10-16 14:40:14 -0500 (Thu, 16 Oct 2008) | 1 line use new showwarnings signature for idle #3391 ........
This commit is contained in:
parent
d586c4ed2b
commit
352ebae87e
2 changed files with 12 additions and 6 deletions
|
@ -55,18 +55,22 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
def idle_showwarning(message, category, filename, lineno):
|
def idle_showwarning(message, category, filename, lineno,
|
||||||
|
file=None, line=None):
|
||||||
file = warning_stream
|
file = warning_stream
|
||||||
try:
|
try:
|
||||||
file.write(warnings.formatwarning(message, category, filename, lineno))
|
file.write(warnings.formatwarning(message, category, filename,\
|
||||||
|
lineno, file=file, line=line))
|
||||||
except IOError:
|
except IOError:
|
||||||
pass ## file (probably __stderr__) is invalid, warning dropped.
|
pass ## file (probably __stderr__) is invalid, warning dropped.
|
||||||
warnings.showwarning = idle_showwarning
|
warnings.showwarning = idle_showwarning
|
||||||
def idle_formatwarning(message, category, filename, lineno):
|
def idle_formatwarning(message, category, filename, lineno,
|
||||||
|
file=None, line=None):
|
||||||
"""Format warnings the IDLE way"""
|
"""Format warnings the IDLE way"""
|
||||||
s = "\nWarning (from warnings module):\n"
|
s = "\nWarning (from warnings module):\n"
|
||||||
s += ' File \"%s\", line %s\n' % (filename, lineno)
|
s += ' File \"%s\", line %s\n' % (filename, lineno)
|
||||||
line = linecache.getline(filename, lineno).strip()
|
line = linecache.getline(filename, lineno).strip() \
|
||||||
|
if line is None else line
|
||||||
if line:
|
if line:
|
||||||
s += " %s\n" % line
|
s += " %s\n" % line
|
||||||
s += "%s: %s\n>>> " % (category.__name__, message)
|
s += "%s: %s\n>>> " % (category.__name__, message)
|
||||||
|
|
|
@ -24,11 +24,13 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
def idle_formatwarning_subproc(message, category, filename, lineno):
|
def idle_formatwarning_subproc(message, category, filename, lineno,
|
||||||
|
file=None, line=None):
|
||||||
"""Format warnings the IDLE way"""
|
"""Format warnings the IDLE way"""
|
||||||
s = "\nWarning (from warnings module):\n"
|
s = "\nWarning (from warnings module):\n"
|
||||||
s += ' File \"%s\", line %s\n' % (filename, lineno)
|
s += ' File \"%s\", line %s\n' % (filename, lineno)
|
||||||
line = linecache.getline(filename, lineno).strip()
|
line = linecache.getline(filename, lineno).strip() \
|
||||||
|
if line is None else line
|
||||||
if line:
|
if line:
|
||||||
s += " %s\n" % line
|
s += " %s\n" % line
|
||||||
s += "%s: %s\n" % (category.__name__, message)
|
s += "%s: %s\n" % (category.__name__, message)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue