Skip to content

Commit

Permalink
Python: type gets retrieved for python3+
Browse files Browse the repository at this point in the history
  • Loading branch information
forthommel committed May 9, 2023
1 parent 07e2d6f commit 8e25b68
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CepGenAddOns/PythonWrapper/PythonTypes.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CepGen: a central exclusive processes event generator
* Copyright (C) 2013-2022 Laurent Forthomme
* Copyright (C) 2013-2023 Laurent Forthomme
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,9 +31,11 @@ namespace cepgen {
void ObjectPtrDeleter::operator()(PyObject* obj) {
CG_DEBUG("Python:ObjectPtrDeleter").log([&obj](auto& log) {
log << "Destroying object at addr 0x" << obj << " (";
#if PY_VERSION_HEX >= 0x03110000
auto* type = Py_TYPE(obj);
if (type)
log << "type: " << get<std::string>(PyType_GetName(type)) << ", ";
#endif
log << "reference count: " << Py_REFCNT(obj) << ")";
});
Py_DECREF(obj);
Expand Down

0 comments on commit 8e25b68

Please sign in to comment.