mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Breaking ground for PEP 3137 implementation:
Get rid of buffer(). Use memoryview() in its place where possible. In a few places, do things a bit different, because memoryview() can't slice (yet).
This commit is contained in:
parent
85c1ba5d74
commit
bae07c9baf
24 changed files with 72 additions and 199 deletions
|
@ -1041,8 +1041,11 @@ class Popen(object):
|
|||
|
||||
|
||||
def _communicate(self, input):
|
||||
if isinstance(input, str): # Unicode
|
||||
input = input.encode("utf-8") # XXX What else?
|
||||
if self.stdin:
|
||||
if isinstance(input, str): # Unicode
|
||||
input = input.encode("utf-8") # XXX What else?
|
||||
if not isinstance(input, (bytes, str8)):
|
||||
input = bytes(input)
|
||||
read_set = []
|
||||
write_set = []
|
||||
stdout = None # Return
|
||||
|
@ -1071,7 +1074,8 @@ class Popen(object):
|
|||
# When select has indicated that the file is writable,
|
||||
# we can write up to PIPE_BUF bytes without risk
|
||||
# blocking. POSIX defines PIPE_BUF >= 512
|
||||
bytes_written = os.write(self.stdin.fileno(), buffer(input, input_offset, 512))
|
||||
chunk = input[input_offset : input_offset + 512]
|
||||
bytes_written = os.write(self.stdin.fileno(), chunk)
|
||||
input_offset += bytes_written
|
||||
if input_offset >= len(input):
|
||||
self.stdin.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue