comparison tests/run-tests.py @ 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 d49144a1422f
children
comparison
equal deleted inserted replaced
52316:a820a7a1fce0 52317:0b708a375490
4070 """Return the path to the mercurial package that is actually found by 4070 """Return the path to the mercurial package that is actually found by
4071 the current Python interpreter.""" 4071 the current Python interpreter."""
4072 if self._hgpath is not None: 4072 if self._hgpath is not None:
4073 return self._hgpath 4073 return self._hgpath
4074 4074
4075 cmd = b'"%s" -c "import mercurial; print (mercurial.__path__[0])"' 4075 # PYTHONSAFEPATH (-P) new in 3.11
4076 cmd = _bytes2sys(cmd % PYTHON) 4076 if sys.version_info >= (3, 11, 0):
4077 python_safe_path = b"-P "
4078 else:
4079 python_safe_path = b""
4080
4081 cmd = b'"%s" %s-c "import mercurial; print (mercurial.__path__[0])"'
4082 cmd = _bytes2sys(cmd % (PYTHON, python_safe_path))
4077 4083
4078 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) 4084 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
4079 out, err = p.communicate() 4085 out, err = p.communicate()
4080 4086
4081 self._hgpath = out.strip() 4087 self._hgpath = out.strip()