summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 842cda6..3353053 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -10,6 +10,7 @@ import gc
import socket
import sys
import os
+import re
import platform
import shutil
import warnings
@@ -1056,3 +1057,13 @@ def reap_children():
break
except:
break
+
+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