Bug 1417387 - Don't mix unicode and bytes in clobber code; r=nalexander
authorGregory Szorc <gps@mozilla.com>
Wed, 15 Nov 2017 10:17:26 -0800
changeset 391942 62b191e02145b1220a39dd2034a3f4d7057e133f
parent 391941 6b9dc67f97beede1f64f535979fda82aa35d2593
child 391943 65c49a6c83f3152d1dc021056b2795e17de6bf11
push id32908
push usercbrindusan@mozilla.com
push dateWed, 15 Nov 2017 22:22:51 +0000
treeherdermozilla-central@60b9fa15e427 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1417387, 1416052
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1417387 - Don't mix unicode and bytes in clobber code; r=nalexander 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))