#1733757: the interpreter would hang on shutdown, if the function set by sys.settrace
calls threading.currentThread.

The correction somewhat improves the code, but it was close.
Many thanks to the "with" construct, which turns python code into C calls.

I wonder if it is not better to sys.settrace(None) just after
running the __main__ module and before finalization.
diff --git a/Misc/NEWS b/Misc/NEWS
index e9e736c..945afdf 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@
 Core and builtins
 -----------------
 
+- Issue #1733757: The interpreter would hang on shutdown if the tracing 
+  function set by sys.settrace is still active and happens to call
+  threading.currentThread().
+
 - Patch #1442: properly report exceptions when the PYTHONSTARTUP file
   cannot be executed.