Cannot load resource files when prefix contains non-ASCII characters #307

Open
Vdragon opened this Issue Jun 16, 2014 · 3 comments

2 participants

@Vdragon

Reproduce steps

  1. find a Windows command-line prompt
  2. make; make prefix=軟體\git-cola install
  3. cd 軟體\git-cola
  4. python bin/git-cola

Console output(partial)

Cannot open file 'D:/git-cola/?n??/git-cola/icons:git.svg', because: No such file or directory
Cannot open file 'D:/git-cola/?n??/git-cola/icons:git.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:undo.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:undo.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:git.svg', because: No such file or directory

Cannot open file 'D:/git-cola/icons:git.svg', because: No such file or directory

Reporter's environment

  • Windows 8.1 x86 64-bit(version 6.3 (build 9600))
  • Python 2.7.7(64-bit x86) is in the %PATH%
  • Locale
    • Codepage 950(Big5)
  • git-cola
@Vdragon Vdragon changed the title from Cannot open icon files when prefix contains non-ASCII characters to Cannot open resource files when prefix contains non-ASCII characters Jun 16, 2014
@Vdragon Vdragon changed the title from Cannot open resource files when prefix contains non-ASCII characters to Cannot load resource files when prefix contains non-ASCII characters Jun 17, 2014
@davvid
git-cola member

Hmm. Does it help if you change cola/resources.py so that the icon() function looks like this?

def icon(basename):
    """Return the full path to an icon file given a basename."""
    return os.path.join(icon_dir(), basename)

If so that may be a solution. We're relying on Qt's QtCore.QDir.addSearchPath(), and it is getting passed a unicode string.

If the above doesn't work, undo that change and modify cola/qtcompat.py so that add_search_path() looks like this:

from cola import core

def add_search_path(prefix, path):
    if hasattr(QtCore.QDir, 'addSearchPath'):
        QtCore.QDir.addSearchPath(prefix, core.encode(path))

Let me know if one of these two helps in your setup. The latter is a shot in the dark, the first snippet makes it so that we circumvent Qt's search path feature, so I'm curious whether either of these helps.

I think I'm using utf-8 paths in my tests, and that might be why it seems to work for me. If neither of these work then it may be that the filesystem paths are not utf-8. Let me know what you find.

@Vdragon

Console output(partial) of 1st change:

Cannot open file 'D:/git-cola/3nAe/git-cola/share/git-cola/icons/git.svg', because: ?t?£Y??????w?????|?C
Cannot open file 'D:/git-cola/3nAe/git-cola/share/git-cola/icons/undo.svg', because: ?t?£Y??????w?????|?C
Cannot open file 'D:/git-cola/3nAe/git-cola/share/git-cola/icons/undo.svg', because: ?t?£Y??????w?????|?C
Cannot open file 'D:/git-cola/3nAe/git-cola/share/git-cola/icons/git.svg', because: ?t?£Y??????w?????|?C
Cannot open file 'D:/git-cola/3nAe/git-cola/share/git-cola/icons/git.svg', because: ?t?£Y??????w??

I believe that the 1st change is doing well except for the path encoding problem

Console output(partial) of 2nd change:

Cannot open file 'D:/git-cola/?n??/git-cola/bin/icons:git.svg', because: No such file or directory
Cannot open file 'D:/git-cola/?n??/git-cola/bin/icons:git.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:undo.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:undo.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:git.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:git.svg', because: No such file or directory
Cannot open file 'D:/git-cola/icons:options.svg', because: No such file or directory
@Vdragon Vdragon closed this Jun 17, 2014
@Vdragon

Oops.

@Vdragon Vdragon reopened this Jun 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment