bpo-30223: Add global in regrtest main_in_temp_cwd (#1399)

diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index cbd9185..5702e38 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1647,6 +1647,8 @@
 
 def main_in_temp_cwd():
     """Run main() in a temporary working directory."""
+    global TEMPDIR
+
     # When tests are run from the Python build directory, it is best practice
     # to keep the test files in a subfolder.  It eases the cleanup of leftover
     # files using command "make distclean".