Skip to content
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

Crash with unicode path #761

Closed
TsarVladislav opened this issue May 31, 2018 · 6 comments
Closed

Crash with unicode path #761

TsarVladislav opened this issue May 31, 2018 · 6 comments
Labels

Comments

@TsarVladislav
Copy link

@TsarVladislav TsarVladislav commented May 31, 2018

Hi, I ran into a problem that this library doesn't support unicode in path

I use:

  1. Debian 9
  2. Python 3.5.3
  3. GitPython==2.1.10 (installed by pip3 install GitPython command)

i found old issue, similar to mine, but it doesn't helped me:
#532

Everything works just fine if i will use path without cyrillic letters.
Code what doesn't work:

#!/usr/bin/python3
import git
def main():

    repo = git.Repo.clone_from("https://github.com/gitpython-developers/GitPython.git",
        "/home/vlad/AltSTU-Submodules/Диплом/Microcontroller-Unit-Testing/scripts/")

if __name__ == '__main__':
    main()
Traceback (most recent call last):
  File "gitl.py", line 13, in <module>
    main()
  File "gitl.py", line 9, in main
    "/home/vlad/AltSTU-Submodules/Диплом/Microcontroller-Unit-Testing/scripts/")
  File "/home/vlad/.local/lib/python3.5/site-packages/git/repo/base.py", line 982, in clone_from
    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs)
  File "/home/vlad/.local/lib/python3.5/site-packages/git/repo/base.py", line 933, in _clone
    finalize_process(proc, stderr=stderr)
  File "/home/vlad/.local/lib/python3.5/site-packages/git/util.py", line 333, in finalize_process
    proc.wait(**kwargs)
  File "/home/vlad/.local/lib/python3.5/site-packages/git/cmd.py", line 402, in wait
    stderr = force_bytes(stderr)
  File "/home/vlad/.local/lib/python3.5/site-packages/gitdb/utils/encoding.py", line 16, in force_bytes
    return data.encode(encoding)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 54-59: ordinal not in range(128)

@Byron Byron added the acknowledged label Jun 5, 2018
@Byron
Copy link
Member

@Byron Byron commented Jun 5, 2018

Back in the days when this library was originally conceived, it was very easy to get text encodings wrong, unfortunately.
Given the current state of affairs, is there any good way to deal with this in what I would call 'modern' python?
After all, the actual OS encoding can only be guessed if it is not provided from the outside, and today one might argue that utf-8 is a better default than ascii.

@TsarVladislav
Copy link
Author

@TsarVladislav TsarVladislav commented Jun 7, 2018

Well, as far as i know, python 3 uses UTF-8 by default, so adding

# -*- coding: utf-8 -*-

to my code didn't worked out. I don't know where to look for this bug: in system locale configuration or in library. Can you confirm that, this actually a bug in library?

@Byron
Copy link
Member

@Byron Byron commented Jun 10, 2018

It is a problem with GitPython as it tries to decode something that is not ascii encoded as ascii.
The coding declaration you provided tells python how to decode source code files while making sense of them, and thus not affect the runtime.

@brizjin
Copy link

@brizjin brizjin commented Aug 13, 2018

I have the same error in GitPython 2.1.11. Is there any solutions?

@Byron
Copy link
Member

@Byron Byron commented Oct 14, 2018

@brizjin I don't think there is unless someone contributes a patch.

@Harmon758
Copy link
Member

@Harmon758 Harmon758 commented Feb 18, 2020

This should be fixed with ebf4656 (#955) in v3.0.5. See #920.

@Harmon758 Harmon758 closed this Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.