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

Cannot write the dashboard: 'ascii' codec can't encode characters in position 5-7: ordinal not in range(128) #50

Closed
cyrus-and opened this issue Nov 29, 2016 · 12 comments

Comments

@cyrus-and
Copy link
Owner

cyrus-and commented Nov 29, 2016

From this comment:

Traceback (most recent call last):
File "", line 357, in render
UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-7: ordinal not in range(128)

GDB 7.7 with Python 2.7.4 3.4.0

@cyrus-and
Copy link
Owner Author

@mohit3112 are you able to identify which is the module that causes this error? You can figure this out by disabling all modules then enabling one at a time.

Also, what is it supposed to print?

Thank you.

@cyrus-and cyrus-and added the bug label Nov 29, 2016
@mohit3112
Copy link

@cyrus-and
i don't think it's specific to module , i enabled assembly module only disabled all other still getting this error

@mohit3112
Copy link

@cyrus-and

ok so i just did following

import platform 
print(platform.python_version())

to check the version of python used , out put is 3.4.0

but when i do python --version , i get 2.7.4

@cyrus-and
Copy link
Owner Author

cyrus-and commented Nov 29, 2016

OK, it's normal, the Python version used by GDB may be different from the system-wide version.

@cyrus-and
Copy link
Owner Author

Does this happen with every file you are trying to debug?

For example try the following:

$ gdb $(which sleep)
>>> run 100
(press Ctrl-C)

You should see the dahboard.

@mohit3112
Copy link

mohit3112 commented Nov 30, 2016

@cyrus-and
yes this works problem is when i use
dashboard -output
that gives error

@cyrus-and
Copy link
Owner Author

Oh, I see, I can reproduce that now.

@cyrus-and
Copy link
Owner Author

cyrus-and commented Dec 3, 2016

Can you try to run:

python -c "import sys; print(sys.stdout.encoding)"

and:

echo $LANG

in your shell where you usually run GDB and get the error?

@mohit3112
Copy link

first one gives : UTF-8
second one gives : en_IN

@cyrus-and
Copy link
Owner Author

I can only reproduce your issue on a machine where the locale is set to C, basically no locale, but I'm able to fix the behavior by exporting the UTF-8 variant before starting GDB, in my case:

export LC_CTYPE=C.UTF-8

For example:

$ gdb -nx -ex 'python with open("/dev/null") as f: print(f.encoding)' -ex quit
ANSI_X3.4-1968
$ export LC_CTYPE=C.UTF-8
$ gdb -nx -ex 'python with open("/dev/null") as f: print(f.encoding)' -ex quit
UTF-8

Can you try to run:

gdb -nx -ex 'python with open("/dev/null") as f: print(f.encoding)' -ex quit

@mohit3112
Copy link

yep i got ANSI_X3.4-1968, i tried to export LC_CTYPE=C.UTF-8 and it worked !!

@cyrus-and
Copy link
Owner Author

Good! Now, I'm not sure whether this is a thing I should fix myself or not, to my knowledge Python falls back to that encoding when it cannot figure out the proper encoding from the environment, so probably you're experiencing this because your setup is not UTF-8-ready...

Anyway, you can use an alias, in your .bashrc or whatever so you don't have to export it every time, plus in this way it will only affect GDB:

alias gdb='LC_CTYPE=C.UTF-8 gdb'

I'm closing this for now. Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants