Bug 1417387 - Don't mix unicode and bytes in clobber code; r?build
b6adf66f34c6 (
bug 1416052) changed the value for "fh" when this code
is called. It can now be an io.BytesIO. This type enforces that
arguments are bytes and doesn't perform automatic type coercion like
most other parts of Python 2.
self.topobjdir is a unicode. And unicode_literals isn't in effect
in this file. So convert self.topobjdir to bytes to make BytesIO
happy.
MozReview-Commit-ID: LrWTKFp3ZKT
--- a/python/mozbuild/mozbuild/controller/clobber.py
+++ b/python/mozbuild/mozbuild/controller/clobber.py
@@ -184,17 +184,18 @@ class Clobberer(object):
self._message('Automatic clobbering is not enabled\n'
' (add "mk_add_options AUTOCLOBBER=1" to your '
'mozconfig).')
if cwd.startswith(self.topobjdir) and cwd != self.topobjdir:
return True, False, self._message(
'Cannot clobber while the shell is inside the object directory.')
- print('Automatically clobbering %s' % self.topobjdir, file=fh)
+ objdir = self.topobjdir.encode('utf-8', 'replace')
+ print('Automatically clobbering %s' % objdir, file=fh)
try:
self.remove_objdir(False)
self.ensure_objdir_state()
print('Successfully completed auto clobber.', file=fh)
return True, True, None
except (IOError) as error:
return True, False, self._message(
'Error when automatically clobbering: ' + str(error))