Skip to content

Couldn't get GItPython to work with file name that contains non-ascii characters #348

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
shang-wang opened this issue Aug 31, 2015 · 2 comments

Comments

@shang-wang
Copy link

Hi all:

I'm not able to find any existing solution for this, but I had a python program that handles file uploads. When people upload file with name contains non-ascii characters, my program throws an exception:

File "/apps/nttech/controllers/GitController.py" in commit_all
  99.                                 repo.index.add([os.path.join(r or '', str(endfile))])
File "/spare/local/Projects/pythonbrew/venvs/Python-2.6.6/towerportal/lib/python2.6/site-packages/git/index/base.py" in add
  780.             self.write(ignore_extension_data=not write_extension_data)
File "/spare/local/Projects/pythonbrew/venvs/Python-2.6.6/towerportal/lib/python2.6/site-packages/git/index/base.py" in write
  213.         self._serialize(stream, ignore_extension_data)
File "/spare/local/Projects/pythonbrew/venvs/Python-2.6.6/towerportal/lib/python2.6/site-packages/git/index/base.py" in _serialize
  176.         entries = self._entries_sorted()
File "/spare/local/Projects/pythonbrew/venvs/Python-2.6.6/towerportal/lib/python2.6/site-packages/git/index/base.py" in _entries_sorted
  173.         return sorted(self.entries.values(), key=lambda e: (e.path, e.stage))

Exception Type: UnicodeDecodeError at /contractdb/contract/create/trading/
Exception Value: 'ascii' codec can't decode byte 0xc3 in position 25: ordinal not in range(128)

Is there a solution to this problem? Do I need to do any pre-processing for the file name? Thanks.

@shang-wang
Copy link
Author

Hmm, just read some other issues here, seems like it's fixed in the latest version? I'm using
GitPythonh==1.0.1 but sounds like it's the latest version already. Also tried to download the latest code but still the same. Any thoughts?

@shang-wang
Copy link
Author

I watched the video for issue #331, changed the file name in my program to be unicode, then the problem is solved. Not sure why GitPython is not able to handle it, hope to get an answer from the author.

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

1 participant