Author martin.panter
Recipients Arfrever, amaury.forgeotdarc, berwin22, chris.jerdonek, haypo, mark, martin.panter, merwok, mightyiam, ncoghlan, pitrou, r.david.murray, segfaulthunter, srid
Date 2016-05-17.22:43:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463525031.96.0.571691703392.issue6135@psf.upfronthosting.co.za>
In-reply-to
Content
This seems like a request for extra feature(s), rather than a bug report.

FWIW I agree with Victor’s hesitation in <https://bugs.python.org/issue6135#msg123024>. I doubt it is worth adding special support to have multiple pipes that all use text mode (universal_newlines=True) but with different encoding settings. If you really want this, just add an external TextIOWrapper, or string encoding:

process = Popen(command, stdin=PIPE, stdout=PIPE, ...)

# Manually wrap with TextIOWrapper. Probably risks deadlocking in the general case, due to buffering, so this is a bad idea IMO.
input_writer = io.TextIOWrapper(process.stdin, "iso-8859-1")
output_reader = io.TextIOWrapper(process.stdout, "utf-8")

# Better: use communicate(), or a custom select() loop or similar:
input_string = input_string.encode("iso-8859-1")
[output_string, _] = process.communicate(input_string)
output_string = output_string.decode("utf-8")

Also I’m not enthusiastic about adding encoding etc parameters for a single PIPE scenario. What is wrong with leaving it in binary mode in the Popen call, and encoding, decoding, or using TextIOWrapper as a separate step?
History
Date User Action Args
2016-05-17 22:43:52martin.pantersetrecipients: + martin.panter, amaury.forgeotdarc, ncoghlan, pitrou, haypo, mark, merwok, segfaulthunter, Arfrever, r.david.murray, srid, mightyiam, chris.jerdonek, berwin22
2016-05-17 22:43:51martin.pantersetmessageid: <1463525031.96.0.571691703392.issue6135@psf.upfronthosting.co.za>
2016-05-17 22:43:51martin.panterlinkissue6135 messages
2016-05-17 22:43:51martin.pantercreate