diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-11-02 19:46:32 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-11-03 15:44:41 -0400 |
commit | 608a6196a0ce1bebf66c5ac0cc38a20bfddede9b (patch) | |
tree | 1c78b58d4e7ebcfd7374b163b343f79760f28a4f | |
parent | c95001b130227dde480647fec9a9f745b83db1e2 (diff) | |
download | meson-608a6196a0ce1bebf66c5ac0cc38a20bfddede9b.zip meson-608a6196a0ce1bebf66c5ac0cc38a20bfddede9b.tar.gz meson-608a6196a0ce1bebf66c5ac0cc38a20bfddede9b.tar.bz2 |
python 3.11: suppress an incorrect EncodingWarning
python 3.11 adds a warning that in 3.15, UTF-8 mode will be default.
This is fantastic news, we'd love that. Less fantastic: this warning is
silly, we *want* these checks to be affected. Plus, the recommended
alternative API would (in addition to warning people when UTF-8 mode
removed the problem) also require using a minimum python version of 3.11
(in which the warning was added) or add verbose if/else soup.
The simple, and obvious, approach is to add a warnings filter to hide
it.
-rw-r--r-- | mesonbuild/mesonmain.py | 7 | ||||
-rwxr-xr-x | run_tests.py | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 7eed11d..c276dab 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -240,6 +240,13 @@ def run(original_args, mainfile): # workaround for https://bugs.python.org/issue34624 import warnings warnings.filterwarnings('error', category=EncodingWarning, module='mesonbuild') + # python 3.11 adds a warning that in 3.15, UTF-8 mode will be default. + # This is fantastic news, we'd love that. Less fantastic: this warning is silly, + # we *want* these checks to be affected. Plus, the recommended alternative API + # would (in addition to warning people when UTF-8 mode removed the problem) also + # require using a minimum python version of 3.11 (in which the warning was added) + # or add verbose if/else soup. + warnings.filterwarnings('ignore', message="UTF-8 Mode affects .*getpreferredencoding", category=EncodingWarning) # Meson gets confused if stdout can't output Unicode, if the # locale isn't Unicode, just force stdout to accept it. This tries diff --git a/run_tests.py b/run_tests.py index ead5865..b03cbac 100755 --- a/run_tests.py +++ b/run_tests.py @@ -76,6 +76,15 @@ else: os.environ['PYTHONWARNDEFAULTENCODING'] = '1' # work around https://bugs.python.org/issue34624 os.environ['MESON_RUNNING_IN_PROJECT_TESTS'] = '1' +# python 3.11 adds a warning that in 3.15, UTF-8 mode will be default. +# This is fantastic news, we'd love that. Less fantastic: this warning is silly, +# we *want* these checks to be affected. Plus, the recommended alternative API +# would (in addition to warning people when UTF-8 mode removed the problem) also +# require using a minimum python version of 3.11 (in which the warning was added) +# or add verbose if/else soup. +if sys.version_info >= (3, 10): + import warnings + warnings.filterwarnings('ignore', message="UTF-8 Mode affects .*getpreferredencoding", category=EncodingWarning) def guess_backend(backend_str: str, msbuild_exe: str) -> T.Tuple['Backend', T.List[str]]: # Auto-detect backend if unspecified |