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

Unicaud error on +kitten icat #924

Closed
sirex opened this issue Sep 7, 2018 · 7 comments
Closed

Unicaud error on +kitten icat #924

sirex opened this issue Sep 7, 2018 · 7 comments

Comments

@sirex
Copy link

sirex commented Sep 7, 2018

I got this error:

> kitty +kitten icat Ekrano\ nuotrauka\ iš\ 2018-07-14\ 17-20-23.png 
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/bin/../lib/kitty/__main__.py", line 110, in <module>
    main()
  File "/usr/bin/../lib/kitty/__main__.py", line 101, in main
    namespaced(['+', first_arg[1:]] + sys.argv[2:])
  File "/usr/bin/../lib/kitty/__main__.py", line 61, in namespaced
    func(args[1:])
  File "/usr/bin/../lib/kitty/__main__.py", line 56, in run_kitten
    run_kitten(kitten)
  File "/usr/bin/../lib/kitty/kittens/runner.py", line 95, in run_kitten
    runpy.run_module('kittens.{}.main'.format(kitten), run_name=run_name)
  File "/usr/lib/python3.7/runpy.py", line 208, in run_module
    return _run_code(code, {}, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 327, in <module>
    main()
  File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 310, in main
    process(item, args)
  File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 193, in process
    show(outfile, width, height, fmt, transmit_mode, align=args.align, place=args.place)
  File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 166, in show
    write_gr_cmd(cmd, standard_b64encode(os.path.abspath(outfile).encode(fsenc)))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 44-45: surrogates not allowed

Versions:

> pacman -Q python kitty
python 3.7.0-3
kitty 0.12.0-1

Not sure, maybe error because of file name, that contains an unicode letter?

@kovidgoyal
Copy link
Owner

Works for me with that filename on Arch. And that error is indicating an error with temporary filename/path not input filename. Make sure your TEMP env var is set to /tmp or similar. Or use --transfer-mode=stream to avoid temp files.

@sirex
Copy link
Author

sirex commented Sep 8, 2018

Ok, after digging a bit deeper I found, that issue is with š character, python receives it as \udcc5\udca1. And because of that unicode error is raised:

> python -c "print('\udcc5\udca1')"                                    
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed

I have no idea, how that happens, but it work with pure python:

> python -c "import sys; print(repr(sys.argv[1]))" š                
'š'

But if I do that with kitty, by modifying /usr/lib/kitty/__main__.py and adding print(repr(sys.argv[1])) to the top of main function, I get this:

> kitty š    
'\udcc5\udca1'

So I guess, argument gets corrupted earlier before Python.

I did tried calling kitty with TEMP=/tmp, but that does not work too. --transfer-mode=stream does work.

@kovidgoyal
Copy link
Owner

Make sure you have your locale setup for UTF-8 correctly. LANG should be something like

LANG=en_US.UTF-8

kitty, unlike python assumes utf-8 everywhere.

@sirex
Copy link
Author

sirex commented Sep 8, 2018

Nope:

> LANG=lt_LT.UTF-8 kitty š
'\udcc5\udca1'
> LANG=en_US.UTF-8 kitty š
'\udcc5\udca1'

@kovidgoyal
Copy link
Owner

Then I have no idea, sorry. Works fine for me:

kitty +runpy 'import sys; print(repr(sys.argv[-1]))' š                                                                                      
'š'

@kovidgoyal
Copy link
Owner

Try building kitty from source so it uses your system python, that might fix it.

@kovidgoyal kovidgoyal reopened this Sep 8, 2018
@sirex
Copy link
Author

sirex commented Sep 8, 2018

> kitty +runpy 'import sys; print(repr(sys.argv[-1]))' š
'+runpy'
'\udcc5\udca1'

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