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

UnicodeDecodeError #72

Open
guyskk opened this issue Oct 4, 2015 · 0 comments
Open

UnicodeDecodeError #72

guyskk opened this issue Oct 4, 2015 · 0 comments

Comments

@guyskk
Copy link

guyskk commented Oct 4, 2015

UnicodeDecodeError When filename is"article/python2编码问题.md" or has unicode char

dulwich/index.py(423) build_index_from_tree()
-> full_path = os.path.join(prefix, entry.path)
(Pdb) pp prefix
u'E:/work/py/kkblog/article_repo/\u54c8\u54c8\\guyskk\\webhooks_test'
(Pdb) pp entry.path
'article/python2\xe7\xbc\x96\xe7\xa0\x81\xe9\x97\xae\xe9\xa2\x98.md'
(Pdb) os.path.join(prefix, entry.path)
*** UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 16: ordinal not in range(128)

My script:

# coding:utf-8

def pull_or_clone(dest, repo_url):

    from giturlparse import parse
    from gittle import Gittle
    import os
    p = parse(repo_url)
    user_repo_path = os.path.join(dest, p.owner, p.repo)
    if os.path.exists(user_repo_path):
        repo = Gittle(user_repo_path, origin_uri=repo_url)
        repo.pull()
    else:
        repo = Gittle.clone(repo_url, user_repo_path)

if __name__ == '__main__':
    dest = u"E:/work/py/kkblog/article_repo/哈哈"
    repo_url = u"https://github.com/guyskk/webhooks_test.git"
    pull_or_clone(dest, repo_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant