Remove Utils.ex_stack - use traceback.format_exc()

This commit is contained in:
Thomas Nagy 2017-08-19 11:54:58 +02:00
parent d865bffd88
commit 57087471c1
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
10 changed files with 18 additions and 29 deletions

View File

@ -18,4 +18,4 @@ NEW IN WAF 2.0.0 (preview 4)
* Remove c_preproc.trimquotes
* Remove field_name, type_name, function_name from conf.check() tests
* Remove extras/mem_reducer.py as a better solution has been merged
* Remove Utils.ex_stack (use traceback.format_exc())

1
TODO
View File

@ -1,7 +1,6 @@
Waf 2.0
-------
Merge mem_reducer.py in the mainline
Improve the sorting in TaskGen.post()
Remove ut_exec, ut_cmd from waf_unit_test.py
Better logging?

View File

@ -12,7 +12,7 @@ A :py:class:`waflib.Configure.ConfigurationContext` instance is created when ``w
* hold configuration routines such as ``find_program``, etc
"""
import os, shlex, sys, time, re, shutil
import os, re, shlex, shutil, sys, time, traceback
from waflib import ConfigSet, Utils, Options, Logs, Context, Build, Errors
WAF_CONFIG_LOG = 'config.log'
@ -258,7 +258,7 @@ class ConfigurationContext(Context.Context):
self.fatal('Could not load the Waf tool %r from %r\n%s' % (tool, sys.path, e))
except Exception as e:
self.to_log('imp %r (%r & %r)' % (tool, tooldir, funs))
self.to_log(Utils.ex_stack())
self.to_log(traceback.format_exc())
raise
if funs is not None:
@ -587,7 +587,7 @@ def run_build(self, *k, **kw):
try:
bld.compile()
except Errors.WafError:
ret = 'Test does not build: %s' % Utils.ex_stack()
ret = 'Test does not build: %s' % traceback.format_exc()
self.fatal(ret)
else:
ret = getattr(bld, 'retval', 0)

View File

@ -6,7 +6,7 @@
Runner.py: Task scheduling and execution
"""
import heapq
import heapq, traceback
try:
from queue import Queue
except ImportError:
@ -364,7 +364,7 @@ class Parallel(object):
return tsk.runnable_status()
except Exception:
self.processed += 1
tsk.err_msg = Utils.ex_stack()
tsk.err_msg = traceback.format_exc()
if not self.stop and self.bld.keep:
self.skip(tsk)
if self.bld.keep == 1:

View File

@ -6,7 +6,7 @@
Tasks represent atomic operations such as processes.
"""
import os, re, sys, tempfile
import os, re, sys, tempfile, traceback
from waflib import Utils, Logs, Errors
# task states
@ -312,7 +312,7 @@ class Task(evil):
try:
ret = self.run()
except Exception:
self.err_msg = Utils.ex_stack()
self.err_msg = traceback.format_exc()
self.hasrun = EXCEPTION
# TODO cleanup
@ -328,7 +328,7 @@ class Task(evil):
except Errors.WafError:
pass
except Exception:
self.err_msg = Utils.ex_stack()
self.err_msg = traceback.format_exc()
self.hasrun = EXCEPTION
else:
self.hasrun = SUCCESS

View File

@ -951,8 +951,7 @@ class c_parser(object):
raise PreprocError('could not read the file %r' % node)
except Exception:
if Logs.verbose > 0:
Logs.error('parsing %r failed', node)
traceback.print_exc()
Logs.error('parsing %r failed %s', node, traceback.format_exc())
else:
self.lines.extend(lines)
@ -1048,7 +1047,7 @@ class c_parser(object):
self.ban_includes.add(self.current_file)
except Exception as e:
if Logs.verbose:
Logs.debug('preproc: line parsing failed (%s): %s %s', e, line, Utils.ex_stack())
Logs.debug('preproc: line parsing failed (%s): %s %s', e, line, traceback.format_exc())
def define_name(self, line):
"""

View File

@ -3,7 +3,7 @@
# DC 2008
# Thomas Nagy 2016-2017 (ita)
import os, re
import os, re, traceback
from waflib import Utils, Logs, Errors
from waflib.Tools import fc, fc_config, fc_scan, ar, ccroot
from waflib.Configure import conf
@ -232,7 +232,7 @@ echo LIB=%%LIB%%;%%LIBPATH%%
try:
conf.cmd_and_log(fc + ['/help'], env=env)
except UnicodeError:
st = Utils.ex_stack()
st = traceback.format_exc()
if conf.logger:
conf.logger.error(st)
conf.fatal('ifort: Unicode error - check the code page?')

View File

@ -52,7 +52,7 @@ cmd.exe /C "chcp 1252 & set PYTHONUNBUFFERED=true && set && waf configure"
Setting PYTHONUNBUFFERED gives the unbuffered output.
"""
import os, sys, re
import os, sys, re, traceback
from waflib import Utils, Logs, Options, Errors
from waflib.TaskGen import after_method, feature
@ -213,7 +213,7 @@ echo LIB=%%LIB%%;%%LIBPATH%%
try:
conf.cmd_and_log(cxx + ['/help'], env=env)
except UnicodeError:
st = Utils.ex_stack()
st = traceback.format_exc()
if conf.logger:
conf.logger.error(st)
conf.fatal('msvc: Unicode error - check the code page?')

View File

@ -422,15 +422,6 @@ def num2ver(ver):
return ret
return ver
def ex_stack():
"""
Extracts the stack to display exceptions. Deprecated: use traceback.format_exc()
:return: a string represening the last exception
"""
# TODO remove in waf 2.0
return traceback.format_exc()
def to_list(val):
"""
Converts a string argument to a list by splitting it by spaces.

View File

@ -12,7 +12,7 @@ a file named pdebug.svg in the source directory::
...
"""
import time, sys, re, threading
import re, sys, threading, time, traceback
try:
from Queue import Queue
except:
@ -222,7 +222,7 @@ def process(self):
try:
ret = self.run()
except Exception:
self.err_msg = Utils.ex_stack()
self.err_msg = traceback.format_exc()
self.hasrun = Task.EXCEPTION
# TODO cleanup
@ -238,7 +238,7 @@ def process(self):
except Errors.WafError:
pass
except Exception:
self.err_msg = Utils.ex_stack()
self.err_msg = traceback.format_exc()
self.hasrun = Task.EXCEPTION
else:
self.hasrun = Task.SUCCESS