unicode - Python encoding for pipe.communicate -
I'm calling pipe.communicate
from Python module from Python 2.6. I get the following error from this code:
pop-in pipe = popin (cwd) pipe.communicate (data)
For an arbitrary < Code> cwd , and where data has Unicode (specifically 0xE 9):
Exec Exception: The 'ASCI' codec character U can not contain the '\ xe 9' in position 507: Orderal non in range (128) traceback (most recent call final): ... stdout, stderr = pipe.communicate ( Data) file "/ system / libraries / frames / python. Frameworkwork / version-2.6 / lib / python2.6 / subprocess.py ", line 671, return the dialog in itself ._communicate (input) file" / system / library / framworks / python framework /versions/2.6/lib/python2. 6 / subprocess.py ", in line 1177, _community bytes_written = os.write (self.stdin.fileno (), part)
this is happening, I think, because pipe.communicate ()
ASCII is expecting an encoded string, but data is unicode.
Is this a problem?
Brian
I can be it by changing it Resolved:
Pipe Communications (Data)
pipe.communicate (data.encode ('utf8'))
Although I stand to be right!
Brian
Comments
Post a Comment