MCPcopy Index your code
hub / github.com/RustPython/RustPython / create_stdout

Method create_stdout

Lib/test/libregrtest/run_workers.py:225–245  ·  view source on GitHub ↗

Create stdout temporary file (file descriptor).

(self, stack: contextlib.ExitStack)

Source from the content-addressed store, hash-verified

223 self._popen = None
224
225 def create_stdout(self, stack: contextlib.ExitStack) -> TextIO:
226 """Create stdout temporary file (file descriptor)."""
227
228 if MS_WINDOWS:
229 # gh-95027: When stdout is not a TTY, Python uses the ANSI code
230 # page for the sys.stdout encoding. If the main process runs in a
231 # terminal, sys.stdout uses WindowsConsoleIO with UTF-8 encoding.
232 encoding = locale.getencoding()
233 else:
234 encoding = sys.stdout.encoding
235
236 # gh-94026: Write stdout+stderr to a tempfile as workaround for
237 # non-blocking pipes on Emscripten with NodeJS.
238 # gh-109425: Use "backslashreplace" error handler: log corrupted
239 # stdout+stderr, instead of failing with a UnicodeDecodeError and not
240 # logging stdout+stderr at all.
241 stdout_file = tempfile.TemporaryFile('w+',
242 encoding=encoding,
243 errors='backslashreplace')
244 stack.enter_context(stdout_file)
245 return stdout_file
246
247 def create_json_file(self, stack: contextlib.ExitStack) -> tuple[JsonFile, TextIO | None]:
248 """Create JSON file."""

Callers 1

_runtestMethod · 0.95

Calls 1

enter_contextMethod · 0.80

Tested by

no test coverage detected