From 355fa6c35c5dfc718785d645ce5aa60597efd030 Mon Sep 17 00:00:00 2001 From: Arseniy Terekhin Date: Wed, 18 Aug 2021 19:29:50 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20gdb=5Fpretty=5Fprinter=20failure?= =?UTF-8?q?=20on=20basic=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name can be None, and `re.search` fails on `None`; replaced `re` by `str.startswith` and `str.endswith` --- third_party/gdb_pretty_printer/nlohmann-json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/gdb_pretty_printer/nlohmann-json.py b/third_party/gdb_pretty_printer/nlohmann-json.py index 5bac45f61..c85a383b0 100644 --- a/third_party/gdb_pretty_printer/nlohmann-json.py +++ b/third_party/gdb_pretty_printer/nlohmann-json.py @@ -1,5 +1,4 @@ import gdb -import re class JsonValuePrinter: "Print a json-value" @@ -13,7 +12,8 @@ class JsonValuePrinter: return self.val def json_lookup_function(val): - if re.search("^nlohmann::basic_json<.*>$", val.type.strip_typedefs().name): + name = val.type.strip_typedefs().name + if name and name.startswith("nlohmann::basic_json<") and name.endswith(">"): t = str(val['m_type']) if t.startswith("nlohmann::detail::value_t::"): try: