diff options
| author | 2022-02-15 10:21:01 +0400 | |
|---|---|---|
| committer | 2022-02-15 10:21:01 +0400 | |
| commit | 97c33b5b67ab5bced41111b28e962765ee7f0215 (patch) | |
| tree | 93f2a0c79b0a22c1ebc03e461c9a993491785e6b /resources | |
| parent | Merge pull request #140 from python-discord/bump-uvicorn (diff) | |
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 <[email protected]>
Diffstat (limited to '')
| -rw-r--r-- | resources/unittest_template.py | 8 | 
1 files changed, 4 insertions, 4 deletions
| 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() | 
