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.

Author unused-346748
Recipients unused-346748
Date 2017-07-31.05:01:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501477317.46.0.791551033282.issue31087@psf.upfronthosting.co.za>
In-reply-to
Content
Regardless of the value of `encoding`, StreamReaders returned for the `asyncio.subprocess.Process`'s `stdout` and `stderr` would be in binary mode.

    import sys
    import asyncio
    import subprocess

    async def main():
        sp = await asyncio.create_subprocess_exec('ls', '-la',
                                                  stdin=None,
                                                  stdout=subprocess.PIPE,
                                                  encoding='utf8')
        await sp.wait()
        data = await sp.stdout.read()
        print(data)
        print(isinstance(data, bytes))

    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

There are two naive solutions:

- `create_subprocess_*` could explicitly raise when provided any `encoding` and `errors` (like it now does with `universal_newlines`).

- or implement encoding conversions for StreamReaders (and StreamWriters), and forward those.

Of course it would be better to have conversions, but I don't know how those will have to deal with decoding partially available data - e.g. returning in the middle of surrogate pair, or having only half a codepoint for UTF16. There should likely cache partial data to process at the next read, but this would require rewriting codecs to support partial decode... seems like it's not that easy :(
History
Date User Action Args
2017-07-31 05:01:57unused-346748setrecipients: + unused-346748
2017-07-31 05:01:57unused-346748setmessageid: <1501477317.46.0.791551033282.issue31087@psf.upfronthosting.co.za>
2017-07-31 05:01:57unused-346748linkissue31087 messages
2017-07-31 05:01:57unused-346748create