Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Finkman opened this issue Jan 12, 2023 · 2 comments · Fixed by #3920
Closed

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

Finkman opened this issue Jan 12, 2023 · 2 comments · Fixed by #3920
Assignees
Labels
kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@Finkman
Copy link
Contributor

Finkman commented Jan 12, 2023

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

  • Use python 3.6.10
  • Use gdb 12.1 with python support
  • add source your/path/to/json/tools/gdb_pretty_printer/nlohmann-json.py to ~/.gdbinit
  • Stop at a break point while debugging
  • Inspect a value like: -exec p -pretty on -- this
    • In that case, I let it stop within an instance of a class and would like to know the address of it.

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
Copy link
Contributor Author

Finkman commented Jan 12, 2023

Additional Info. It works fine with json version 3.10.4

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jan 14, 2023
@nlohmann nlohmann self-assigned this Jan 14, 2023
@nlohmann nlohmann added this to the Release 3.11.3 milestone Jan 14, 2023
@nlohmann
Copy link
Owner

Closed by merging #3920.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants