Skip to content

Commit e8660d9

Browse files
Open log files in binary mode for Python 3 comp (#1182)
1 parent 1d59497 commit e8660d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cuegui/cuegui/Utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,17 @@ def getLastLine(path):
459459
ansiEscape = r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]'
460460

461461
try:
462-
fp = open(path, 'r')
462+
fp = open(path, 'rb')
463463
fp.seek(0, 2)
464464

465465
backseek = min(4096, fp.tell())
466466
fp.seek(-backseek, 1)
467467
buf = fp.read(4096)
468468

469-
newline_pos = buf.rfind("\n",0,len(buf)-1)
469+
newline_pos = buf.rfind(b'\n', 0, len(buf)-1)
470470
fp.close()
471471

472-
line = buf[newline_pos+1:].strip()
472+
line = buf[newline_pos+1:].strip().decode("utf-8")
473473

474474
return re.sub(ansiEscape, "", line)
475475
except IOError:

0 commit comments

Comments
 (0)