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.
This commit is contained in:
parent
94a97b2f8d
commit
ec10816665
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue