MCPcopy Create free account
hub / github.com/numpy/numpy / forward_bytes_to_stdout

Function forward_bytes_to_stdout

numpy/distutils/exec_command.py:80–96  ·  view source on GitHub ↗

Forward bytes from a subprocess call to the console, without attempting to decode them. The assumption is that the subprocess call already returned bytes in a suitable encoding.

(val)

Source from the content-addressed store, hash-verified

78
79
80def forward_bytes_to_stdout(val):
81 """
82 Forward bytes from a subprocess call to the console, without attempting to
83 decode them.
84
85 The assumption is that the subprocess call already returned bytes in
86 a suitable encoding.
87 """
88 if hasattr(sys.stdout, 'buffer'):
89 # use the underlying binary output if there is one
90 sys.stdout.buffer.write(val)
91 elif hasattr(sys.stdout, 'encoding'):
92 # round-trip the encoding if necessary
93 sys.stdout.write(val.decode(sys.stdout.encoding))
94 else:
95 # make a best-guess at the encoding
96 sys.stdout.write(val.decode('utf8', errors='replace'))
97
98
99def temp_file_name():

Callers 1

CCompiler_spawnFunction · 0.90

Calls 2

decodeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected