Skip to content

Commit a3f494e

Browse files
committed
Fix deprecated pybind call
1 parent 890280a commit a3f494e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/openPMD/binding/python/Mpi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pythonObjectAsMpiComm(pybind11::object &comm)
9494
e_t::is_not_an_mpi_communicator};
9595
// only checks same layout, e.g. an `int` in `PyObject` could pass this
9696
if (!py::isinstance<py::class_<openPMD_PyMPIIntracommObject> >(
97-
comm.get_type()))
97+
py::type::of(comm)))
9898
// TODO add mpi4py version from above import check to error message
9999
return e{
100100
"comm has unexpected type layout in " + comm_str +

src/binding/python/Attributable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ template <typename RequestedType>
275275
bool setAttributeFromObject_default(
276276
Attributable &attr, std::string const &key, py::object &obj)
277277
{
278-
if (std::string(py::str(obj.get_type())) == "<class 'list'>")
278+
if (std::string(py::str(py::type::of(obj))) == "<class 'list'>")
279279
{
280280
using ListType = std::vector<RequestedType>;
281281
return attr.setAttribute<ListType>(key, obj.cast<ListType>());
@@ -289,7 +289,7 @@ bool setAttributeFromObject_default(
289289
bool setAttributeFromObject_double(
290290
Attributable &attr, std::string const &key, py::object &obj)
291291
{
292-
if (std::string(py::str(obj.get_type())) == "<class 'list'>")
292+
if (std::string(py::str(py::type::of(obj))) == "<class 'list'>")
293293
{
294294
using ListType = std::vector<double>;
295295
using ArrayType = std::array<double, 7>;
@@ -342,7 +342,7 @@ std::optional<TargetType> tryCast(py::object const &obj)
342342
{
343343
TargetType val{};
344344
auto python_val = py::cast(std::move(val));
345-
if (!py::isinstance(obj, python_val.get_type()))
345+
if (!py::isinstance(obj, py::type::of(python_val)))
346346
{
347347
return std::nullopt;
348348
}

0 commit comments

Comments
 (0)