Patchwork run-tests: avoid set PYTHONUSERBASE environment variable to None

login
register
mail settings
Submitter Mihai Popescu
Date Jan. 8, 2018, 1:23 p.m.
Message ID <CAF2xkU4REH+YNo=rcFTzBRUGob=-23Tyg-hzsE-sX8+Ne-FGwg@mail.gmail.com>
Download mbox | patch
Permalink /patch/26626/
State Accepted
Headers show

Comments

Mihai Popescu - Jan. 8, 2018, 1:23 p.m.
# HG changeset patch
# User Mihai Popescu <mihai@unity3d.com>
# Date 1515415963 -3600
#      Mon Jan 08 13:52:43 2018 +0100
# Node ID 913c426a392121e6f629f591374b8a10d55c05ea
# Parent  4c3a4bb31c0e3d9b8920b4c9b64ae930b1fe52ce
run-tests: avoid set PYTHONUSERBASE environment variable to None

According to python documentation, get_config_var can return None and it was
during running mercurial tests under a virtual environment with the local
built
mercurial installed as a python package with `pip install -e .`.

On the other hand, if mercurial is installed in the user library folders
with
`pip install --local -e .` the issue doesn't reproduce.

The fallback is that it will just set an empty string and everything should
work
as before, according to https://www.python.org/dev/peps/pep-0370/:

    The path to the user base directory can be overwritten with the
environment
    variable PYTHONUSERBASE. The default location is used when
PYTHONUSERBASE is
    not set or empty.
Yuya Nishihara - Jan. 10, 2018, 1:12 p.m.
On Mon, 08 Jan 2018 13:23:13 +0000, Mihai Popescu wrote:
> # HG changeset patch
> # User Mihai Popescu <mihai@unity3d.com>
> # Date 1515415963 -3600
> #      Mon Jan 08 13:52:43 2018 +0100
> # Node ID 913c426a392121e6f629f591374b8a10d55c05ea
> # Parent  4c3a4bb31c0e3d9b8920b4c9b64ae930b1fe52ce
> run-tests: avoid set PYTHONUSERBASE environment variable to None

Queued for stable, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1037,7 +1037,7 @@ 
             offset = '' if i == 0 else '%s' % i
             env["HGPORT%s" % offset] = '%s' % (self._startport + i)
         env = os.environ.copy()
-        env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase')
+        env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
         env['HGEMITWARNINGS'] = '1'
         env['TESTTMP'] = self._testtmp
         env['HOME'] = self._testtmp