Decode bytes before using os.path.join

Otherwise it will raise TypeError when trying to join str() and bytes() instance 
in python-3.3.

Fixes #654
Closes #655
This commit is contained in:
ZyX 2014-04-23 06:31:42 +04:00
parent b856fa5a82
commit ba45a002dc
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,9 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, absolute_import, print_function)
import os
import sys
import re
from powerline.lib.vcs import get_branch_name as _get_branch_name, get_file_status
@ -26,7 +29,7 @@ def git_directory(directory):
if os.path.isfile(path):
with open(path, 'rb') as f:
raw = f.read().partition(b':')[2].strip()
return os.path.abspath(os.path.join(directory, raw))
return os.path.abspath(os.path.join(directory, raw.decode(sys.getfilesystemencoding() or 'utf-8')))
else:
return path