My wish for TempFile is fulfilled.
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 6f76cb5..4cf9609 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -776,7 +776,7 @@
 
         """
         import tempfile
-        return tempfile.TemporaryFile("w+")
+        return tempfile.TemporaryFile("w+", encoding="utf-8", newline="\n")