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

Unicode failure #21

Open
N7DR opened this issue May 10, 2020 · 11 comments
Open

Unicode failure #21

N7DR opened this issue May 10, 2020 · 11 comments

Comments

@N7DR
Copy link

N7DR commented May 10, 2020

If I have an ordinary gnuplot script file that contains, say, the line:
set xlabel "β(°)"
Then, when executed, gnuplot does the expected and labels the x axis with the text "β(°)".

If I put exactly the same text into a cell that is run with the gnuplot jupyter kernel, then both of the non-ASCII characters appear in the label as garbled.

The same failure is apparent in titles.

@has2k1
Copy link
Owner

has2k1 commented May 10, 2020

I think it is an issue with your installation. Trying out your unicode string with this notebook gives me unicode in the output.

gnuplot-unicode

@N7DR
Copy link
Author

N7DR commented May 10, 2020 via email

@has2k1
Copy link
Owner

has2k1 commented May 11, 2020

I don't see anything attached!

What version of python is it?

@N7DR
Copy link
Author

N7DR commented May 11, 2020 via email

@N7DR
Copy link
Author

N7DR commented May 11, 2020 via email

@has2k1
Copy link
Owner

has2k1 commented May 12, 2020

Okay, I have seen the same issue at binder.

@N7DR
Copy link
Author

N7DR commented May 12, 2020 via email

@has2k1
Copy link
Owner

has2k1 commented May 12, 2020

That link did work, but I tried it https://mybinder.org/v2/gh/has2k1/gnuplot_kernel/master?filepath=examples and I got the exact garbled output as in https://www.adrive.com/public/yFJpnM/Screenshot_20200510_162329.png.

After some debugging on the containers at binder , I have tracked the failure to pass on unicode to somewhere between the pexpect library (that is part of the requirements) and the gnuplot installation. For my system with the same versions of pexpect and gnuplot, unicode works well. For the binder system, pexpect with sh can pass between themselves unicode strings, while pexpect with gnuplot mess up the unicode handling

A snapshot of the debugging

gnuplot-unicode-debug

Code

# Send some unicode string to the shell and see what it prints
import pexpect
spawn_cmd = '/bin/sh'
child = pexpect.spawnu(spawn_cmd, echo=False)
cmd = 'echo "β(°)"'
child.sendline(cmd)
child.readline()
res = child.before
res
# Send some unicode string to gnuplot and see what it prints
import pexpect
spawn_cmd = '/usr/bin/gnuplot'
#child = pexpect.spawn(spawn_cmd, encoding='utf-8')
child = pexpect.spawnu(spawn_cmd, encoding='utf-8')
cmd = 'print "β(°)"'
child.sendline(cmd)
child.readline()
res = child.buffer.split()[-2]
res

@N7DR
Copy link
Author

N7DR commented May 12, 2020 via email

@has2k1
Copy link
Owner

has2k1 commented May 14, 2020

python3-pexpect is version 4.6.0-1

I have ruled out pexpect and its only dependency ptyprocess by testing the minimum required versions pexpect-4.2.0 and ptyprocess-0.5.0 and my system. With those versions unicode strings are handled correctly.

That effectively rules out the python packages, but not the installed CPython (esp. it's compilation environment) and the general OS environment. With that I am out of moves.

@N7DR
Copy link
Author

N7DR commented May 14, 2020 via email

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