Bug 1417387 - Don't mix unicode and bytes in clobber code; r?build draft
authorGregory Szorc <gps@mozilla.com>
Wed, 15 Nov 2017 10:17:26 -0800
changeset 698432 1f7951c86fd7e5799743a505552c23a63d02285a
parent 698261 45715ece25fcb064eee4f977ebd842d44a87f22b
child 740374 30ee0f03c6a61697677cea54b5e11df55e6c5ba4
push id89283
push userbmo:gps@mozilla.com
push dateWed, 15 Nov 2017 18:17:38 +0000
reviewersbuild
bugs1417387, 1416052
milestone59.0a1
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
python/mozbuild/mozbuild/controller/clobber.py
--- 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))