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

Problem with non-ascii filenames #2

Closed
GoogleCodeExporter opened this issue Aug 23, 2015 · 3 comments
Closed

Problem with non-ascii filenames #2

GoogleCodeExporter opened this issue Aug 23, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

Repositories with non-ascii filenames from Windows causes problems in Linux 
environment:
Traceback (most recent call last):
  File "/home/legogris/gitinspector/gitinspector.py", line 135, in <module>
    __run__.output()
  File "/home/legogris/gitinspector/gitinspector.py", line 59, in output
    outputable.output(blame.BlameOutput(self.hard))
  File "/home/legogris/gitinspector/outputable.py", line 37, in output
    outputable.output_text()
  File "/home/legogris/gitinspector/blame.py", line 210, in output_text
    get(self.hard)
  File "/home/legogris/gitinspector/blame.py", line 149, in get
    __blame__ = Blame(hard)
  File "/home/legogris/gitinspector/blame.py", line 97, in __init__
    if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
  File "/home/legogris/gitinspector/changes.py", line 58, in is_valid_extension
    extension = FileDiff.get_extension(string)
  File "/home/legogris/gitinspector/changes.py", line 48, in get_extension
    string = FileDiff.get_filename(string)
  File "/home/legogris/gitinspector/changes.py", line 54, in get_filename
    return codecs.getdecoder('unicode_escape')(string.strip())[0]
UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-17: 
ordinal not in range(128)



Replacing FileDiff.get_extension and get_filename in change.py with the 
following fixes the issue for me:

@staticmethod
def get_extension(string):
  string = FileDiff.get_filename(string)
  return os.path.splitext(string)[1][1:]

@staticmethod
def get_filename(string):
  string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'").encode('latin-1')                   
  return codecs.getdecoder('unicode_escape')(string.strip())[0]

Original issue reported on code.google.com by robert.e...@gmail.com on 13 May 2013 at 9:58

@GoogleCodeExporter
Copy link
Author

Hi Robert.

Your solution would break utf-8 encoded strings. There are also compatibility 
issues between Python 2 and 3. The 2.1 release of gitinspector should work just 
fine with Python 3. In the meantime, this bug should already have been fixed in 
the master branch in revision 35214550f35f.

Try checking out the current master branch and try again. It should hopefully 
fix it.

/Adam Waldenberg

Original comment by gitinspe...@ejwa.se on 13 May 2013 at 11:26

  • Changed state: Invalid

@GoogleCodeExporter
Copy link
Author

It seems there are still some issues related to this. I will take a look as 
soon as possible. "unicode-escape" and "string-escape" behave slightly 
different and these problems were introduced with the Python 3 fixes that were 
done previously.

/Adam Waldenberg

Original comment by gitinspe...@ejwa.se on 15 May 2013 at 12:00

  • Changed state: Started
  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision cf40f16119ab.

Original comment by gitinspe...@ejwa.se on 16 May 2013 at 1:07

  • Changed state: Fixed

@adam-waldenberg adam-waldenberg self-assigned this Oct 9, 2015
@adam-waldenberg adam-waldenberg added this to the 0.2.2 milestone Nov 1, 2015
allmightyspiff pushed a commit to allmightyspiff/gitinspector that referenced this issue Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants