Fixed AttributeError: 'str' object has no attribute 'decode'
When git cmd fails, raw_version_list is set to empty 'str' and then we are trying to decode it. This patch moves decoding inside try/catch block, so we are decoding return value of subprocess call, which is bytes in Python 3. Change-Id: Ibd2f556355a6413beb21473ebfca3b836cbc1d73
This commit is contained in:
parent
3bcdfc6b77
commit
5c765d5561
@ -55,14 +55,13 @@ def _get_other_versions(app):
|
|||||||
try:
|
try:
|
||||||
raw_version_list = subprocess.Popen(
|
raw_version_list = subprocess.Popen(
|
||||||
git_cmd, stdout=subprocess.PIPE).communicate()[0]
|
git_cmd, stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
raw_version_list = raw_version_list.decode("utf8")
|
||||||
except OSError:
|
except OSError:
|
||||||
app.warn('Cannot get tags from git repository. '
|
app.warn('Cannot get tags from git repository. '
|
||||||
'Not setting "other_versions".')
|
'Not setting "other_versions".')
|
||||||
raw_version_list = ''
|
raw_version_list = u''
|
||||||
|
|
||||||
# grab last five that start with a number and reverse the order
|
# grab last five that start with a number and reverse the order
|
||||||
if six.PY3:
|
|
||||||
raw_version_list = raw_version_list.decode("utf8")
|
|
||||||
_tags = [t.strip("'") for t in raw_version_list.split('\n')]
|
_tags = [t.strip("'") for t in raw_version_list.split('\n')]
|
||||||
other_versions = [
|
other_versions = [
|
||||||
t for t in _tags if t and t[0] in string.digits
|
t for t in _tags if t and t[0] in string.digits
|
||||||
|
Loading…
Reference in New Issue
Block a user