This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 martin.panter
收信人 Arfrever, amaury.forgeotdarc, berwin22, chris.jerdonek, eric.araujo, mark, martin.panter, mightyiam, ncoghlan, pitrou, r.david.murray, segfaulthunter, srid, vstinner
日期 2016-05-17.22:43:51
SpamBayes Score -1.0
Marked as misclassified
Message-id <1463525031.96.0.571691703392.issue6135@psf.upfronthosting.co.za>
In-reply-to
内容
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?
历史
日期 用户 动作 参数
2016-05-17 22:43:52martin.panter修改recipients: + martin.panter, amaury.forgeotdarc, ncoghlan, pitrou, vstinner, mark, eric.araujo, segfaulthunter, Arfrever, r.david.murray, srid, mightyiam, chris.jerdonek, berwin22
2016-05-17 22:43:51martin.panter修改messageid: <1463525031.96.0.571691703392.issue6135@psf.upfronthosting.co.za>
2016-05-17 22:43:51martin.panter链接issue6135 messages
2016-05-17 22:43:51martin.panter创建