From e62ae024ae099b6c6a42ea4ebe806272e1a2fb52 Mon Sep 17 00:00:00 2001 From: Denis Fortin Date: Wed, 27 Jul 2022 17:56:01 +0200 Subject: Handle garbage in environment more gracefully when setting vsenv Environment line may not contain '=' and thus fail to decompose into a key/value pair. --- mesonbuild/mesonlib/vsenv.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mesonbuild/mesonlib/vsenv.py b/mesonbuild/mesonlib/vsenv.py index 0d37765..4eab428 100644 --- a/mesonbuild/mesonlib/vsenv.py +++ b/mesonbuild/mesonlib/vsenv.py @@ -96,8 +96,13 @@ def _setup_vsenv(force: bool) -> bool: continue if not bat_line: continue - k, v = bat_line.split('=', 1) - os.environ[k] = v + try: + k, v = bat_line.split('=', 1) + except ValueError: + # there is no "=", ignore junk data + pass + else: + os.environ[k] = v return True def setup_vsenv(force: bool = False) -> bool: -- cgit v1.1