From 084cd0ae3d9e84626e7da728e653f3a74149191b Mon Sep 17 00:00:00 2001 From: Alan Justino Date: Sat, 12 Oct 2019 16:29:53 +0200 Subject: [PATCH] sys.std{in,out,err} implemented in the most simple way - It respects what already exists if any - Otherwise it opens de UNIX standard files Caveats: - May be not on the proper place - Is open to discussion on what codec, or if should be opened as bytes - Can be also done in Rust side --- Lib/_sitebuiltins.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/_sitebuiltins.py b/Lib/_sitebuiltins.py index c29cf4bf8..f6a0e1c2e 100644 --- a/Lib/_sitebuiltins.py +++ b/Lib/_sitebuiltins.py @@ -10,6 +10,11 @@ The objects used by the site module to add custom builtins. import sys +sys.stdin = getattr(sys, 'stdin', False) or open('/dev/stdin') +sys.stdout = getattr(sys, 'stdout', False) or open('/dev/stdout', 'w') +sys.stderr = getattr(sys, 'stderr', False) or open('/dev/stderr', 'w') + + class Quitter(object): def __init__(self, name, eof): self.name = name