Skip to content

Systems with non-English locales fail in some cases #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
earwig opened this issue May 30, 2015 · 7 comments
Closed

Systems with non-English locales fail in some cases #290

earwig opened this issue May 30, 2015 · 7 comments

Comments

@earwig
Copy link

earwig commented May 30, 2015

Previously reported as #68, this is still broken. The current insufficient fix is here: git/cmd.py#552

Originally reported downstream here: earwig/git-repo-updater#11

Steps to reproduce:

  • Ensure a non-English locale is available on your system. In my case (Ubuntu 14.04 LTS), I had to do sudo locale-gen fr_FR.UTF-8 && sudo dpkg-reconfigure locales
  • export LANGUAGE=fr_FR.UTF-8
  • export LC_ALL=fr_FR.UTF-8
  • python -c "import git; git.Repo('path/to/a/repo').remote().fetch()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/earwig/.local/lib/python2.7/site-packages/GitPython-1.0.1-py2.7.egg/git/remote.py", line 651, in fetch
    res = self._get_fetch_info_from_stderr(proc, progress or RemoteProgress())
  File "/home/earwig/.local/lib/python2.7/site-packages/GitPython-1.0.1-py2.7.egg/git/remote.py", line 588, in _get_fetch_info_from_stderr
    for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))
  File "/home/earwig/.local/lib/python2.7/site-packages/GitPython-1.0.1-py2.7.egg/git/remote.py", line 588, in <genexpr>
    for err_line, fetch_line in zip(fetch_info_lines, fetch_head_info))
  File "/home/earwig/.local/lib/python2.7/site-packages/GitPython-1.0.1-py2.7.egg/git/remote.py", line 241, in _from_line
    raise ValueError("Failed to parse line: %r" % line)
ValueError: Failed to parse line: u' = [\xe0 jour]          develop    -> origin/develop'
Byron added a commit that referenced this issue May 31, 2015
Previously, only program messages where forced to the C-locale, now
we force the entire program. That way, we should assure a remote
will not provide us with branch information in any other language but
english.

Related to #290
@Byron
Copy link
Member

Byron commented May 31, 2015

I am still trying to reproduce the issue on a VM, but have nonetheless provided a potential fix. You might be able to verify it earlier than I do - I will however keep you posted.

Byron added a commit that referenced this issue May 31, 2015
This is a pre-emptive measure based on http://goo.gl/l74GC8 .

Related to #290
@Byron
Copy link
Member

Byron commented May 31, 2015

Please try the latest master - even on a virtual machine I was unable to get git into non-english mode, for some reason. Any other program I used (e.g. ls, date) reported in french, as expected.

@Byron Byron added this to the v1.0.2 - Fixes milestone May 31, 2015
@Byron
Copy link
Member

Byron commented May 31, 2015

You can watch the development stream on youtube.

GitPython #2 [fix issue 290 - enforce C locale]

thumb

@earwig
Copy link
Author

earwig commented Jun 1, 2015

Thanks for uploading the video, it was interesting to watch. Sorry to make you spend a while on something I hoped wouldn't take very long!

I'm not sure why you weren't able to get git in another language. I followed nearly the same procedure as you in the VM and I was able to do it. These things tend to be shaky, so maybe it's down to a difference in Ubuntu version or installed packages?

At any rate, the provided fix works for me. I asked the original reporter to test it, but I suspect it will work for him too.

@Byron
Copy link
Member

Byron commented Jun 1, 2015

Good to hear ! Please feel free to close this issue once it works for the upstream reporter.

NOTE: I'd probably want to make a new release on pypi, but unfortunately they lost support for OpenID, which terminated my account as well. There is no way for me to login, and the site to reset an account doesn't work either ... . I will reach out to @empty to re-authenticate the new account I made.

@nvie
Copy link
Contributor

nvie commented Aug 28, 2015

I've seen the following variant of this error sometimes when this is emitted from the underlying ssh command:

ValueError: Failed to parse line: "Warning: Permanently added the RSA host key for IP address '192.30.***.***' to the list of known hosts."

The initial git command thus fails, but retrying it typically makes it work again since the warning is not emitted a second time.

Perhaps a solution could be to ignore lines starting with Warning: ?

@Byron
Copy link
Member

Byron commented Aug 29, 2015

@nvie Warning lines could be ignored above this line quite nicely. It might even work assuming that the language of ssh is always changed to english if GitPython invokes git with the respective environment variable set.

If you would like to get your hands dirty and submit a PR, I'd happily merge it.
Thanks and cheers !

@Byron Byron closed this as completed Aug 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants