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
 
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 027f87e..3957258 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -241,7 +241,7 @@
         # mark". Otherwise, it may not be possible anymore to
         # reset the overflowed flag to 0.
 
-        from _testcapi import get_recursion_depth
+        from _testinternalcapi import get_recursion_depth
 
         def set_recursion_limit_at_depth(depth, limit):
             recursion_depth = get_recursion_depth()