Use bytes for python3 friendly os.write

Bytes not str. Otherwise we get
TypeError: a bytes-like object is required, not 'str'
in the metadata proxy and it dies.

Closes-Bug: #1661303
Change-Id: If6b6f19130c965436a637a03a4cf72203e0786b0
This commit is contained in:
Kevin Benton 2017-02-02 16:12:40 -08:00
parent 9ed660af9e
commit 33129f2ac6
2 changed files with 2 additions and 2 deletions

View File

@ -136,7 +136,7 @@ class Pidfile(object):
def write(self, pid):
os.ftruncate(self.fd, 0)
os.write(self.fd, "%d" % pid)
os.write(self.fd, b"%d" % pid)
os.fsync(self.fd)
def read(self):

View File

@ -181,7 +181,7 @@ class TestPidfile(base.BaseTestCase):
self.os.assert_has_calls([
mock.call.ftruncate(FAKE_FD, 0),
mock.call.write(FAKE_FD, '34'),
mock.call.write(FAKE_FD, b'34'),
mock.call.fsync(FAKE_FD)]
)