mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 09:57:15 +01:00
Don't fail on output decoding errors
This commit is contained in:
parent
43302767dd
commit
bfcef62e45
@ -116,6 +116,12 @@ class store_context(type):
|
||||
ctx = store_context('ctx', (object,), {})
|
||||
"""Base class for all :py:class:`waflib.Context.Context` classes"""
|
||||
|
||||
def decode(out):
|
||||
try:
|
||||
return out.decode(sys.stdout.encoding or 'iso8859-1', errors='replace')
|
||||
except TypeError: # Python <= 2.6
|
||||
return out.decode(sys.stdout.encoding or 'iso8859-1')
|
||||
|
||||
class Context(ctx):
|
||||
"""
|
||||
Default context for waf commands, and base class for new command contexts.
|
||||
@ -355,14 +361,14 @@ class Context(ctx):
|
||||
|
||||
if out:
|
||||
if not isinstance(out, str):
|
||||
out = out.decode(sys.stdout.encoding or 'iso8859-1')
|
||||
out = decode(out)
|
||||
if self.logger:
|
||||
self.logger.debug('out: %s', out)
|
||||
else:
|
||||
Logs.info(out, extra={'stream':sys.stdout, 'c1': ''})
|
||||
if err:
|
||||
if not isinstance(err, str):
|
||||
err = err.decode(sys.stdout.encoding or 'iso8859-1')
|
||||
err = decode(err)
|
||||
if self.logger:
|
||||
self.logger.error('err: %s' % err)
|
||||
else:
|
||||
@ -440,9 +446,9 @@ class Context(ctx):
|
||||
raise Errors.WafError('Execution failure: %s' % str(e), ex=e)
|
||||
|
||||
if not isinstance(out, str):
|
||||
out = out.decode(sys.stdout.encoding or 'iso8859-1')
|
||||
out = decode(out)
|
||||
if not isinstance(err, str):
|
||||
err = err.decode(sys.stdout.encoding or 'iso8859-1')
|
||||
err = decode(err)
|
||||
|
||||
if out and quiet != STDOUT and quiet != BOTH:
|
||||
self.to_log('out: %s' % out)
|
||||
|
Loading…
Reference in New Issue
Block a user