python/mozbuild: Use str instead of bytes in manifest.

This commit is contained in:
Vincent Povirk 2019-08-14 15:12:02 -05:00 committed by Jacek Caban
parent 7547326b1f
commit 07ce014820

View File

@ -115,7 +115,7 @@ class InstallManifest(object):
self._source_files = set()
if path or fileobj:
with _auto_fileobj(path, fileobj, 'rb') as fh:
with _auto_fileobj(path, fileobj, 'r') as fh:
self._source_files.add(fh.name)
self._load_from_fileobj(fh)
@ -174,7 +174,7 @@ class InstallManifest(object):
dest, content = fields[1:]
self.add_content(
self._decode_field_entry(content).encode('utf-8'), dest)
self._decode_field_entry(content), dest)
continue
# Don't fail for non-actionable items, allowing
@ -236,7 +236,7 @@ class InstallManifest(object):
It is an error if both are specified.
"""
with _auto_fileobj(path, fileobj, 'wb') as fh:
with _auto_fileobj(path, fileobj, 'w') as fh:
fh.write('%d\n' % self.CURRENT_VERSION)
for dest in sorted(self._dests):
@ -244,8 +244,7 @@ class InstallManifest(object):
parts = ['%d' % entry[0], dest]
parts.extend(entry[1:])
fh.write('%s\n' % self.FIELD_SEPARATOR.join(
p.encode('utf-8') for p in parts))
fh.write('%s\n' % self.FIELD_SEPARATOR.join(parts))
def add_symlink(self, source, dest):
"""Add a symlink to this manifest.
@ -391,7 +390,7 @@ class InstallManifest(object):
if install_type == self.CONTENT:
# GeneratedFile expect the buffer interface, which the unicode
# type doesn't have, so encode to a str.
content = self._decode_field_entry(entry[1]).encode('utf-8')
content = self._decode_field_entry(entry[1])
registry.add(dest, GeneratedFile(content))
continue