aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2023-08-08 08:41:01 +0200
committerEli Schwartz <eschwartz93@gmail.com>2023-08-08 16:32:39 -0400
commitec1081666578fe33a75f2c03b6ee9582806d012f (patch)
treea53ee1e2f8fc8b472350264ed504a166ef2a5c5c
parent94a97b2f8d11772ee96740026119414164f1617a (diff)
downloadmeson-ec1081666578fe33a75f2c03b6ee9582806d012f.zip
meson-ec1081666578fe33a75f2c03b6ee9582806d012f.tar.gz
meson-ec1081666578fe33a75f2c03b6ee9582806d012f.tar.bz2
tests: fix test_vsenv_option with Python 3.11+ on Windows
meson tests enable PYTHONWARNDEFAULTENCODING by default and make EncodingWarning fatal too. Starting with Python 3.11 CPython not only warns if no encoding is passed to open() but also to things like subprocess.check_output(). This made the call in vsenv.py fail and in turn made test_vsenv_option fail. check_output() here calls a .bat file which in turn calls vcvars. I don't know what the encoding is supposed to be used there, so just be explicit with the locale encoding to silence the warning.
-rw-r--r--mesonbuild/utils/vsenv.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/utils/vsenv.py b/mesonbuild/utils/vsenv.py
index 550a8cf..5a02379 100644
--- a/mesonbuild/utils/vsenv.py
+++ b/mesonbuild/utils/vsenv.py
@@ -6,6 +6,7 @@ import json
import pathlib
import shutil
import tempfile
+import locale
from .. import mlog
from .core import MesonException
@@ -93,7 +94,8 @@ def _setup_vsenv(force: bool) -> bool:
bat_file.write(bat_contents)
bat_file.flush()
bat_file.close()
- bat_output = subprocess.check_output(bat_file.name, universal_newlines=True)
+ bat_output = subprocess.check_output(bat_file.name, universal_newlines=True,
+ encoding=locale.getpreferredencoding(False))
os.unlink(bat_file.name)
bat_lines = bat_output.split('\n')
bat_separator_seen = False