magicmonty/bash-git-prompt — pull request #33 by fernandolopez (2014-01-01 23:40:07+00:00)
Title: Fixed to work in Pyton 3.2/3.3

In both Python 3.2 and 3.3.3 Popen.communicate() returns a tuple of bytes and some operations expects something of type str, this causes problems in two lines of the code (when showing the commit hash and when there are untracked files).

The proposed fix, solves this two issues and is tested in Python 2.6, 2.7, 3.2 and 3.3.3.

The exceptions raised were the following:

1 - If there are untracked files, it fails with the next message:
$ python3.2 ~/.gitprompt/gitstatus.py
Traceback (most recent call last):
File "/home/prog/.gitprompt/gitstatus.py", line 67, in
untracked_lines = [a for a in status_lines if a.startswith("??")]
File "/home/prog/.gitprompt/gitstatus.py", line 67, in
untracked_lines = [a for a in status_lines if a.startswith("??")]
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

2 - In "detached HEAD" mode:
$ python3.2 ~/.gitprompt/gitstatus.py Traceback (most recent call last):
File "/home/prog/.gitprompt/gitstatus.py", line 83, in
branch = symbols['prehash']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1]
TypeError: Can't convert 'bytes' object to str implicitly