bpo-39947: Move get_recursion_depth() to _testinternalcapi (GH-18974)

Move get_recursion_depth() function from _testcapi to
_testinternalcapi to avoid accessing PyThreadState attributes
directly in _testcapi.
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 2d3a13a..d6739f1 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -994,7 +994,7 @@
         # finalization of these locals.
         code = """if 1:
             import sys
-            from _testcapi import get_recursion_depth
+            from _testinternalcapi import get_recursion_depth
 
             class MyException(Exception): pass