Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.
This repository was archived by the owner on May 3, 2024. It is now read-only.

Additional python debug output on missing __dict__ #66

Closed
@EinarElen

Description

@EinarElen

When working on LDMX-sw, it isn't uncommon to break your python configuration files. One of the most annoying to debug is the missing dict one. I think it would be good to print a repr of the PyObject* before throwing the exception (or include the repr in the exception message).

Taking inspiration from the existing getPyString, something equivalent to

static void pretty_print(PyObject* object) {
  PyObject* repr = PyObject_Repr(object);  // Get string representation
  if (repr != nullptr) {
    const char* str = PyUnicode_AsUTF8(repr);  
    if (str != nullptr) {
      std::cout << "Python object: " << str
                << std::endl;
    }
    Py_XDECREF(repr);
  }
}

should probably do the trick

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions