Factor out stripping of interpreter debug output in test.support.strip_python_stderr()
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 558fbc2..0372f16 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -1243,3 +1243,13 @@
             yield
         finally:
             del obj[item]
+
+def strip_python_stderr(stderr):
+    """Strip the stderr of a Python process from potential debug output
+    emitted by the interpreter.
+
+    This will typically be run on the result of the communicate() method
+    of a subprocess.Popen object.
+    """
+    stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
+    return stderr