nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
42.18k stars 6.65k forks source link

json pretty printer causes python exceptions on non-json types #3919

Closed Finkman closed 1 year ago

Finkman commented 1 year ago

Description

I am using version 3.11.2 and added the pretty printer to my gdb with

source ${workspaceFolder}/libs/json/tools/gdb_pretty_printer/nlohmann-json.py

When debugging, inspecting json values is working fine. Inspecting the value of a pointer or anything that is not json pops an error on the gdb console

Reproduction steps

Expected vs. actual results

Gdb pops an error on the screen. While I am using VSCode, this stops the pretty-printed values of the variable of being visible.

grafik

Minimal code example

No response

Error messages

Output of -exec p -pretty on -- this

Python Exception <class 'TypeError'>: expected string or bytes-like object
Python Exception <class 'TypeError'>: expected string or bytes-like object
$2 = (DemoPlugin * const) 0x5555555da2f0


### Compiler and operating system

Ubuntu 22.04, gdb 12.1, python 3.6.10, gnu gcc 11

### Library version

3.11.2

### Validation

- [X] The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used.
- [X] I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests).
Finkman commented 1 year ago

Additional Info. It works fine with json version 3.10.4

nlohmann commented 1 year ago

Closed by merging #3920.