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

Crashes if a package's description is not in English #88

Closed
OneOfOne opened this issue May 8, 2018 · 9 comments
Closed

Crashes if a package's description is not in English #88

OneOfOne opened this issue May 8, 2018 · 9 comments
Labels
invalid This doesn't seem right

Comments

@OneOfOne
Copy link

OneOfOne commented May 8, 2018

Description

If a package's name or description has unicode characters, aurman crashes.

Expected Behavior

Not Crash.

Current Behavior

Well, it crashes.

Possible Solution

in aurman/utilities.py line 99:

replace:
print("    {}".format(ret_dict['Description']))

with:
print("    {}".format(ret_dict['Description'].encode('utf-8')))

Steps to Reproduce

➤ aurman -Ss peek
aur/peek 1.3.1-1 (70, 5.963747)
Simple screen recorder with an easy to use interface
aur/cardpeek 0.8.4-1 (6, 0.456978)
A tool to read-only the contents of smartcards
aur/peek-git 1.3.1.r45.g22b9fe0-1 (5, 0.007787)
Simple screen recorder with an easy to use interface (latest development release)
aur/cardpeek-svn 206-1 (4, 0)
A tool to read the contents of smartcards
aur/diod-git 1.0.24.r11.g0ea3fe3-1 (0, 0)
A multi-threaded, user space file server that speeks 9P2000.L
aur/peekvc 0.1-1 (0, 0)
Dumps the the current state of a Linux virtual console
aur/poplines 2.1.1-2 (0, 0)
Tools to pop/peek lines from the head/tail or known position within a given file, and output to stdout. Makes files into queues!
aur/python-poplines 2.1.1-2 (0, 0)
Tools to pop/peek lines from the head/tail or known position within a given file, and output to stdout. Makes files into queues!
aur/python2-poplines 2.1.1-2 (0, 0)
Tools to pop/peek lines from the head/tail or known position within a given file, and output to stdout. Makes files into queues!
aur/readesm-fr 2.4-1 (0, 0)
2018-05-09 00:38:06,072 - main - main - ERROR - 
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aurman/main.py", line 526, in main
    process(argv[1:])
  File "/usr/lib/python3.6/site-packages/aurman/main.py", line 225, in process
    search_and_print(search, installed_system, str(pacman_args), repo, aur)
  File "/usr/lib/python3.6/site-packages/aurman/utilities.py", line 99, in search_and_print
    print("    {}".format(ret_dict['Description']))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 94: ordinal not in range(128)
@polygamma polygamma reopened this May 9, 2018
@polygamma
Copy link
Owner

What locale have you set on your system? Do you use Arch or something like Manjaro?

@polygamma polygamma added the question Further information is requested label May 9, 2018
@OneOfOne
Copy link
Author

OneOfOne commented May 9, 2018

I'm using Arch.

➤ localectl
   System Locale: LANG=en_US.utf8
                  LANGUAGE=en_US
       VC Keymap: n/a
      X11 Layout: n/a

➤ locale
LANG=en_US.utf8
LC_CTYPE=en_US.utf8
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

➤ python -V; python -c 'import sys; print(sys.getdefaultencoding(), sys.stdin.encoding, sys.stdout.encoding)'
Python 3.6.5
utf-8 UTF-8 UTF-8

➤ uname -a
Linux Ava 4.16.6-1-ARCH #1 SMP PREEMPT Mon Apr 30 12:30:03 UTC 2018 x86_64 GNU/Linux

@OneOfOne
Copy link
Author

OneOfOne commented May 9, 2018

I added print(sys.getdefaultencoding(), sys.stdin.encoding, sys.stdout.encoding) before line 99 in aurman/utilities.py and I got this:

utf-8 ANSI_X3.4-1968 ANSI_X3.4-1968 <<<<<<<<<<

2018-05-09 15:44:21,221 - main - main - ERROR - 
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aurman/main.py", line 526, in main
    process(argv[1:])
  File "/usr/lib/python3.6/site-packages/aurman/main.py", line 225, in process
    search_and_print(search, installed_system, str(pacman_args), repo, aur)
  File "/usr/lib/python3.6/site-packages/aurman/utilities.py", line 100, in search_and_print
    print("    {}".format(ret_dict['Description']))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 94: ordinal not in range(128)

@polygamma
Copy link
Owner

polygamma commented May 9, 2018

The error has to be on your side, adding
print(sys.getdefaultencoding(), sys.stdin.encoding, sys.stdout.encoding) before line 99 yields on my pc:
utf-8 UTF-8 UTF-8

May you change your locale to en_US.UTF-8 and try it again? Notice the - between UTF and the 8

@OneOfOne
Copy link
Author

OneOfOne commented May 9, 2018

That does actually fix it, thanks.

@polygamma
Copy link
Owner

You're welcome :)

@polygamma polygamma added invalid This doesn't seem right and removed question Further information is requested labels May 9, 2018
@arfoll
Copy link

arfoll commented Jun 9, 2018

Had similar issue because my locale wasn't set to utf-8 correctly - this helped me diagnose it so thanks!

@c3ypt1c
Copy link

c3ypt1c commented Jun 10, 2018

Had the same issue. Glad this exists to help me fix.

@polygamma
Copy link
Owner

have added an entry to the FAQ in the README reagarding this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants