![](https://secure.gravatar.com/avatar/25fd96d509520bac1f394a867a1d9b30.jpg?s=120&d=mm&r=g)
Andrew Barnert <abarnert@yahoo.com.dmarc.invalid> writes:
On Monday, September 1, 2014 1:10 PM, Akira Li <4kir4.1i@gmail.com> wrote:
Paul Moore <p.f.moore@gmail.com> writes:
On 1 September 2014 20:14, Akira Li <4kir4.1i@gmail.com> wrote:
Could you provide examples how the final result could look like?
Do you mean what I'm proposing?
p = Popen(..., encoding='utf-8') p.stdout is now a text stream assuming the data is in UTF8, rather than assuming it's in the default encoding.
What if you want to specify an error handler e.g., to read a file list from `find -print0` -like program: you could pass errors='surrogateescape', newlines='\0' (issue1152248) to TextIOWrapper(p.stdin).
Presumably you either meant passing them to `TextIOWrapper(p.stdout)` for `find -print0`, or passing them to `TextIOWrapper(p.stdin)` for xargs -0`; find doesn't even look at its input.
You are right. I've looked at 'surrogateescape' that means reading, that is associated with sys.stdin; so I wrote p.stdin instead of p.stdout by mistake. -- Akira