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
Ondřej Nový
7 years ago
54 | 54 | try: |
55 | 55 | raw_version_list = subprocess.Popen( |
56 | 56 | git_cmd, stdout=subprocess.PIPE).communicate()[0] |
57 | raw_version_list = raw_version_list.decode("utf8") | |
57 | 58 | except OSError: |
58 | 59 | app.warn('Cannot get tags from git repository. ' |
59 | 60 | 'Not setting "other_versions".') |
60 | raw_version_list = '' | |
61 | raw_version_list = u'' | |
61 | 62 | |
62 | 63 | # grab last five that start with a number and reverse the order |
63 | if six.PY3: | |
64 | raw_version_list = raw_version_list.decode("utf8") | |
65 | 64 | _tags = [t.strip("'") for t in raw_version_list.split('\n')] |
66 | 65 | other_versions = [ |
67 | 66 | t for t in _tags if t and t[0] in string.digits |