Skip to content

Commit

Permalink
restartcheck: fix python 3 bytestring breakage
Browse files Browse the repository at this point in the history
In python 2, bytes is an alias for str and b'foo' == 'foo' so this code
used to work, but in python 3 bytes is a separate type, b'foo' != 'foo'
so pth.startswith() errors because of the type mismatch:

"Passed invalid arguments: startswith first arg must be bytes or a
tuple of bytes, not str."

Fix this by converting bytes to an unicode string so the code works in
both v2 and v3.

Signed-off-by: Ioan-Adrian Ratiu <[email protected]>
  • Loading branch information
Ioan-Adrian Ratiu committed Dec 5, 2018
1 parent 1a51bab commit 9831191
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion salt/modules/restartcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def restartcheck(ignorelist=None, blacklist=None, excludepid=None, **kwargs):

while True:
_check_timeout(start_time, timeout)
line = paths.stdout.readline()
line = salt.utils.stringutils.to_unicode(paths.stdout.readline())
if not line:
break
pth = line[:-1]
Expand Down

0 comments on commit 9831191

Please sign in to comment.