pexpect and unicode strings

M

Mathew Oakes

Is there anything that can be done to make pexpect spawns send unicode lines?

In this example they are just middot characters, but this process
needs to be able to handle languages in other character sets.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/pexpect.py", line 961, in sendline
n = self.send(s)
File "/usr/lib/python2.6/dist-packages/pexpect.py", line 953, in send
c = os.write(self.child_fd, s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in
position 41: ordinal not in range(128)
Help appreciated!

cheeers
Mat
 
S

Sean DiZazzo

Is there anything that can be done to make pexpect spawns send unicode lines?

In this example they are just middot characters, but this process
needs to be able to handle languages in other character sets.


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/pexpect.py", line 961, in sendline
    n = self.send(s)
  File "/usr/lib/python2.6/dist-packages/pexpect.py", line 953, in send
    c = os.write(self.child_fd, s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in
position 41: ordinal not in range(128)



Help appreciated!

cheeers
Mat

Did you trying changing line 953 in the pexpect file to:

c = os.write(self.child_fd, s.encode("utf-8"))

and then run your code again?

Worth a shot. I have no good way of trying it out here.

~Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top