Always check `__stdout__` before using
Hard to be sure, but [this issue](https://developercommunity.visualstudio.com/content/problem/175588/adjusting-console-output.html) seems like it could be fixed by verifying `__stdout__` is not None before using it.
diff --git a/Python/Product/PythonTools/ptvsd/debugger.py b/Python/Product/PythonTools/ptvsd/debugger.py
index 4244cf058..c06953435 100644
--- a/Python/Product/PythonTools/ptvsd/debugger.py
+++ b/Python/Product/PythonTools/ptvsd/debugger.py
@@ -2533,16 +2533,17 @@ def new_external_thread():
     sys.settrace(thread.trace_func)
 
 def do_wait():
-    try:
-        import msvcrt
-    except ImportError:
-        sys.__stdout__.write('Press Enter to continue . . . ')
-        sys.__stdout__.flush()
-        sys.__stdin__.read(1)
-    else:
-        sys.__stdout__.write('Press any key to continue . . . ')
-        sys.__stdout__.flush()
-        msvcrt.getch()
+    if sys.__stdout__ is not None:
+        try:
+            import msvcrt
+        except ImportError:
+            sys.__stdout__.write('Press Enter to continue . . . ')
+            sys.__stdout__.flush()
+            sys.__stdin__.read(1)
+        else:
+            sys.__stdout__.write('Press any key to continue . . . ')
+            sys.__stdout__.flush()
+            msvcrt.getch()
 
 def enable_output_redirection():
     sys.stdout = _DebuggerOutput(sys.stdout, 'stdout')
['Python/Product/PythonTools/ptvsd/debugger.py']