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

Unable to launch editor when PATH env. var. cantains non-ASCII characters #807

Closed
brlin-tw opened this issue Apr 21, 2018 · 5 comments
Closed

Comments

@brlin-tw
Copy link
Contributor

brlin-tw commented Apr 21, 2018

Reproducing Instruction

  1. Run env PATH="工:$PATH" git cola in a Git repository in a terminal
  2. Select a file in status widget
  3. Select "Launch editor" option in the contextual menu

Expected Behavior

Editor launched without errors

Current Behavior

Editor not launched with the following error:

Traceback

Traceback (most recent call last):

  File "/home/Lin-Buo-Ren/.local/share/git-cola/lib/cola/cmds.py", line 1231, in do
    core.fork(utils.shell_split(editor) + opts)

  File "/home/Lin-Buo-Ren/.local/share/git-cola/lib/cola/decorators.py", line 23, in _caller
    return caller(f, *args, **opts)

  File "/home/Lin-Buo-Ren/.local/share/git-cola/lib/cola/decorators.py", line 75, in interruptable
    result = func(*args, **opts)

  File "/home/Lin-Buo-Ren/.local/share/git-cola/lib/cola/core.py", line 260, in _fork_posix
    return subprocess.Popen(encoded_args, cwd=cwd).pid

  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)

  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)

Traceback (Original)

  File "/usr/local/share/git-cola/lib/cola/cmds.py", line 2365, in do
    return cmd.do()

  File "/usr/local/share/git-cola/lib/cola/cmds.py", line 1194, in do
    details = core.decode(e.strerror)

AttributeError: 'exceptions.UnicodeDecodeError' object has no attribute 'strerror'

git config

gui.editor=kate --startanon
gui.historybrowser=gitk
cola.boldheaders=true
cola.tabwidth=4
cola.linebreak=false
cola.spellcheck=false
cola.fontdiff=Noto Sans Mono CJK TC,11,-1,5,50,0,0,0,0,0
cola.showpath=false
@davvid
Copy link
Member

davvid commented Apr 21, 2018

Python2 or Python3?

davvid added a commit to davvid/git-cola that referenced this issue Apr 21, 2018
Related-to: git-cola#807
Reported-by: 林博仁 <Buo.Ren.Lin@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid
Copy link
Member

davvid commented Apr 21, 2018

I pushed up a commit which should fix this traceback and give us more details about what's going on. Please let me know what it's reporting now.

It's curious that we got a UnicodeDecode error. Are the filenames ascii, or non-utf8?

@brlin-tw
Copy link
Contributor Author

brlin-tw commented Apr 22, 2018

Python2 or Python3?

Python 2, and to be specific:

Git Cola version 3.0 (v3.0-217-ga1f4867c)

-   Linux-4.13.0-38-generic-x86_64-with-neon-16.04-xenial
-   Python (/usr/bin/python) 2.7.12 (default, Dec 4 2017, 14:50:18) \[GCC 5.4.0 20160609\]
-   Git 2.17.0
-   Qt 5.10.0
-   QtPy 1.3.1
-   PyQt5 5.9.2

Are the filenames ascii, or non-utf8?

The filename to be editted is in ASCII AFAICT

Please let me know what it's reporting now.

Cannot exec "kate --startanon": please configure your editor

Traceback (most recent call last):

  File "/usr/local/share/git-cola/lib/cola/cmds.py", line 1190, in do
    core.fork(utils.shell_split(editor) + opts)

  File "/usr/local/share/git-cola/lib/cola/decorators.py", line 23, in _caller
    return caller(f, *args, **opts)

  File "/usr/local/share/git-cola/lib/cola/decorators.py", line 75, in interruptable
    result = func(*args, **opts)

  File "/usr/local/share/git-cola/lib/cola/core.py", line 260, in _fork_posix
    return subprocess.Popen(encoded_args, cwd=cwd).pid

  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)

  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 18: ordinal not in range(128)

@davvid
Copy link
Member

davvid commented May 4, 2018

Hmm byte 0xe8 is è is it possible that the filename starts with that unicode character? Your editor, kate --startanon is 16 characters long, so position 18 should be the very first character of the filename since there's a space before that at position 17.

This is pretty weird because we handle utf-8 encoded filenames just fine. Do you happen to have a repo that you can post somewhere that can demonstrate the problem?

@brlin-tw
Copy link
Contributor Author

brlin-tw commented May 4, 2018

Your editor, kate --startanon is 16 characters long, so position 18 should be the very first character of the filename since there's a space before that at position 17.

My guess is it has to do with my PATH configuration: /home/Lin-Buo-Ren/工作空間/第三方專案/vdent - Verilog Indenter - Simple indent program for Verilog source code. Trims end of line white space and indents lines based on nested depth of code blocks/bin:/home/Lin-Buo-Ren/.cargo/bin:/home/Lin-Buo-Ren/.gem/ruby/2.3.0/bin:/home/Lin-Buo-Ren/工作空間/第三方專案/iStyle - Fast and Free Automatic Formatter for Verilog Source Code/bin/release:/home/Lin-Buo-Ren/.cabal/bin:/home/Lin-Buo-Ren/軟體/BFG Repo-Cleaner:/home/Lin-Buo-Ren/bin:/home/Lin-Buo-Ren/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin, which the 18th character is '工' (0xe5, 0xb7, 0xa5).

I've reset the PATH environmental variable and the editor successfully launched.

@brlin-tw brlin-tw changed the title LaunchEditor exception: AttributeError("'exceptions.UnicodeDecodeError' object has no attribute 'strerror'",) Unable to launch editor when PATH env. var. cantains non-ASCII characters May 18, 2018
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
Related-to: git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
Related-to: git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
Related-to: git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
Related-to: git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
Related-to: git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
Related-to: git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue May 18, 2018
* type-safety:
  doc: update v3.2 release notes draft
  core: ensure that unencoded strings are encoded
  tests: eliminate type(obj)
  utils: eliminate type(obj)
  qtutils: eliminate type(obj)
  gitcmds: eliminate type(obj)
  gitcfg: eliminate type(obj)
  settings: eliminate type(obj)
  settings: add docstrings
  .gitignore: add .cache

Closes git-cola#807
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid davvid closed this as completed in 5c83b36 May 18, 2018
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

2 participants