Exception handling enhancements

This commit is contained in:
Thomas Nagy 2016-02-28 14:23:54 +01:00
parent 3ced4c6695
commit b4437f3b51
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
4 changed files with 11 additions and 9 deletions

View File

@ -191,7 +191,7 @@ class BuildContext(Context.Context):
def __copy__(self):
"""Implemented to prevents copies of build contexts (raises an exception)"""
raise Errors.WafError('build contexts are not supposed to be copied')
raise Errors.WafError('build contexts cannot be copied')
def install_files(self, *k, **kw):
"""Actual implementation provided by :py:meth:`waflib.Build.InstallContext.install_files`"""

View File

@ -416,7 +416,7 @@ class Context(ctx):
to_ret = STDOUT
if Logs.verbose and not kw['shell'] and not Utils.check_exe(cmd[0]):
raise Errors.WafError("Program %s not found!" % cmd[0])
raise Errors.WafError("Program %r not found!" % cmd[0])
kw['stdout'] = kw['stderr'] = subprocess.PIPE
if quiet is None:

View File

@ -229,7 +229,7 @@ def h_file(fname):
from waflib import Utils
def h_file(fname):
st = os.stat(fname)
if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
if stat.S_ISDIR(st[stat.ST_MODE]): raise OSError('not a file')
s = "%s%s%s" % (st.st_mtime, st.st_size, fname)
return Utils.md5(s.encode()).digest()
Utils.h_file = h_file
@ -290,7 +290,7 @@ def writef_win32(f, data, m='w', encoding='ISO8859-1'):
try:
fd = os.open(f, flags)
except OSError:
raise IOError('Cannot write to %r' % f)
raise OSError('Cannot write to %r' % f)
f = os.fdopen(fd, m)
try:
f.write(data)
@ -301,7 +301,7 @@ def h_file_win32(fname):
try:
fd = os.open(fname, os.O_BINARY | os.O_RDONLY | os.O_NOINHERIT)
except OSError:
raise IOError('Cannot read from %r' % fname)
raise OSError('Cannot read from %r' % fname)
f = os.fdopen(fd, 'rb')
m = md5()
try:

View File

@ -61,12 +61,14 @@ def r1(code):
"utf-8 fixes for python < 2.6"
code = code.replace('as e:', ',e:')
code = code.replace(".decode(sys.stdout.encoding or 'iso8859-1')", '')
code = code.replace('.encode()', '')
return code
return code.replace('.encode()', '')
@subst('Runner.py')
def r4(code):
"generator syntax"
code = code.replace('next(self.biter)', 'self.biter.next()')
return code
return code.replace('next(self.biter)', 'self.biter.next()')
@subst('Context.py')
def r4(code):
return code.replace("('Execution failure: %s'%str(e),ex=e)", "('Execution failure: %s'%str(e),ex=e),None,sys.exc_info()[2]")