I don't like the proposed change: - Find where the Unicode string firstly appeared and convert it there. - Sources have unit tests so write a test to cover this issue
I would much prefer to only encode if url is actually a unicode instance. As is, the code would crash if someone has older GitPython (that returns strs), and the url actually contains non-ascii characters.
url
unicode
str
>>> "ščř".encode('utf-8') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 0: ordinal not in range(128)
I have rebase the patch on master and merged.