1
0
mirror of https://github.com/nlohmann/json synced 2024-11-22 20:10:06 +00:00

🚨 gdb_pretty_printer failure on basic types

name can be None, and `re.search` fails on `None`;
replaced `re` by `str.startswith` and `str.endswith`
This commit is contained in:
Arseniy Terekhin 2021-08-18 19:29:50 +03:00 committed by GitHub
parent f42a74b8f5
commit 355fa6c35c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: