summaryrefslogtreecommitdiff
path: root/mesonbuild/mintro.py
diff options
context:
space:
mode:
authorVolker Weißmann <volker.weissmann@gmx.de>2025-03-24 18:14:25 +0100
committerDylan Baker <dylan@pnwbakers.com>2025-05-29 09:20:27 -0700
commite7e25842c2b38be3df86cc7ddfd57988da9a141b (patch)
treed3453ae5c2e59acc52edb909cb9ca3331a7d09a3 /mesonbuild/mintro.py
parentcab5c8e2b73fc6084ead0f6bf61a649e0c4be1f5 (diff)
downloadmeson-e7e25842c2b38be3df86cc7ddfd57988da9a141b.tar.gz
rewriter: Bugfix concerning `UnknownValue`
Without this commit, the static introspection tool crashes when introspecting systemd since certain values are `UnknownValue` which was unexpected. (I tested sytemd's commit hash fefcb935cd.)
Diffstat (limited to 'mesonbuild/mintro.py')
-rw-r--r--mesonbuild/mintro.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index db62dc06c..6986186bd 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -31,6 +31,12 @@ if T.TYPE_CHECKING:
from .interpreter import Interpreter
+class IntrospectionEncoder(json.JSONEncoder):
+ def default(self, obj: T.Any) -> T.Any:
+ if isinstance(obj, UnknownValue):
+ return 'unknown'
+ return json.JSONEncoder.default(self, obj)
+
def get_meson_info_file(info_dir: str) -> str:
return os.path.join(info_dir, 'meson-info.json')
@@ -492,12 +498,12 @@ def print_results(options: argparse.Namespace, results: T.Sequence[T.Tuple[str,
return 1
elif len(results) == 1 and not options.force_dict:
# Make to keep the existing output format for a single option
- print(json.dumps(results[0][1], indent=indent))
+ print(json.dumps(results[0][1], indent=indent, cls=IntrospectionEncoder))
else:
out = {}
for i in results:
out[i[0]] = i[1]
- print(json.dumps(out, indent=indent))
+ print(json.dumps(out, indent=indent, cls=IntrospectionEncoder))
return 0
def get_infodir(builddir: T.Optional[str] = None) -> str: