pudb icon indicating copy to clipboard operation
pudb copied to clipboard

UnicodeEncodeError: 'latin-1' codec can't encode character '\u21a6' i

Open Shekharrajak opened this issue 5 years ago • 5 comments

While debugging using pudb I got this error in between:

byte_count = len(line[i:i+column_count].encode(_target_encoding))
UnicodeEncodeError: 'latin-1' codec can't encode character '\u21a6' in position 3: ordinal not in range(256)

Anybody already know these error, then please let me know how to takle it.

Thanks!

Shekharrajak avatar Apr 08 '19 08:04 Shekharrajak

We'll need an example file to reproduce this bug in order to help you. Also, are you on Python2 or 3? What version of pudb?

inducer avatar Apr 09 '19 15:04 inducer

Also what is the output of the locale command?

asmeurer avatar Apr 17 '19 20:04 asmeurer

This is the output for locale command :

shekharrajak@HackerDude ➜  ~  locale
LANG=en_IN
LANGUAGE=en_IN:en
LC_CTYPE=en_IN
LC_NUMERIC="en_IN"
LC_TIME="en_IN"
LC_COLLATE="en_IN"
LC_MONETARY="en_IN"
LC_MESSAGES="en_IN"
LC_PAPER="en_IN"
LC_NAME="en_IN"
LC_ADDRESS="en_IN"
LC_TELEPHONE="en_IN"
LC_MEASUREMENT="en_IN"
LC_IDENTIFICATION="en_IN"
LC_ALL=

I will share the example file to repproduce it .

Shekharrajak avatar Apr 18 '19 08:04 Shekharrajak

The issue will probably go away if you set your locale to en_IN.UTF-8. See https://www.cyberciti.biz/faq/how-to-set-locales-i18n-on-a-linux-unix/.

Even so, pudb shouldn't crash on characters that it can't encode.

asmeurer avatar Apr 22 '19 18:04 asmeurer

Thannks @asmeurer , I will try it out.

Shekharrajak avatar Apr 23 '19 08:04 Shekharrajak