From 97c33b5b67ab5bced41111b28e962765ee7f0215 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Tue, 15 Feb 2022 10:21:01 +0400 Subject: Patch `sys.__stdout__` In Code Questions Patching just `sys.stdout` allowed users to still access stdout via `sys.__stdout__`. The same was true for stderr. Both have been explicitly patched now. Signed-off-by: Hassan Abouelela --- resources/unittest_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'resources/unittest_template.py') diff --git a/resources/unittest_template.py b/resources/unittest_template.py index 2410278..990d077 100644 --- a/resources/unittest_template.py +++ b/resources/unittest_template.py @@ -72,12 +72,12 @@ try: DEVNULL = SimpleNamespace(write=lambda *_: None, flush=lambda *_: None) RESULT = io.StringIO() - ORIGINAL_STDOUT = sys.stdout + ORIGINAL_STDOUT = sys.__stdout__ # stdout/err is patched in order to control what is outputted by the runner - sys.stdout = DEVNULL - sys.stderr = DEVNULL - + sys.__stdout__ = sys.stdout = DEVNULL + sys.__stderr__ = sys.stderr = DEVNULL + # Load the user code as a global module variable try: module = _load_user_module() -- cgit v1.2.3