changeset 52317:0b708a375490 default tip

tests: use PYTHONSAFEPATH (-P) to check mercurial lib path
author paugier <pierre.augier@univ-grenoble-alpes.fr>
date Mon, 21 Oct 2024 23:10:37 +0200
parents a820a7a1fce0
children
files tests/run-tests.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Thu Nov 21 11:46:10 2024 -0500
+++ b/tests/run-tests.py	Mon Oct 21 23:10:37 2024 +0200
@@ -4072,8 +4072,14 @@
         if self._hgpath is not None:
             return self._hgpath
 
-        cmd = b'"%s" -c "import mercurial; print (mercurial.__path__[0])"'
-        cmd = _bytes2sys(cmd % PYTHON)
+        # PYTHONSAFEPATH (-P) new in 3.11
+        if sys.version_info >= (3, 11, 0):
+            python_safe_path = b"-P "
+        else:
+            python_safe_path = b""
+
+        cmd = b'"%s" %s-c "import mercurial; print (mercurial.__path__[0])"'
+        cmd = _bytes2sys(cmd % (PYTHON, python_safe_path))
 
         p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
         out, err = p.communicate()