Commit e01527cd by Ralf W. Grosse-Kunstleve Committed by Copybara-Service

Resolve pybind11 deprecation warning.

Observed while locally testing https://github.com/pybind/pybind11_abseil/pull/7:

```
In file included from /usr/local/google/home/rwgk/forked/pybind11_abseil/pybind11_abseil/tests/absl_example.cc:23:
/usr/local/google/home/rwgk/forked/pybind11_abseil/pybind11_abseil/absl_casters.h: In member function ‘bool pybind11::detail::type_caster<absl::lts_20211102::Duration>::load(pybind11::handle, bool)’:
/usr/local/google/home/rwgk/forked/pybind11_abseil/pybind11_abseil/absl_casters.h:194:48: warning: ‘bool pybind11::handle::operator==(const pybind11::handle&) const’ is deprecated: Use obj1.is(obj2) instead [-Wdeprecated-declarations]
  194 |     if (src == object(py_duration_t.attr("max"))) {
      |                                                ^
In file included from /usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/detail/type_caster_base.h:12,
                 from /usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/cast.h:15,
                 from /usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/attr.h:14,
                 from /usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/detail/class.h:1,
                 from /usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/pybind11.h:13,
                 from /usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/complex.h:12,
                 from /usr/local/google/home/rwgk/forked/pybind11_abseil/pybind11_abseil/tests/absl_example.cc:6:
/usr/local/google/home/rwgk/forked/pybind11_abseil/tmp_build/_deps/pybind11-src/include/pybind11/pytypes.h:290:10: note: declared here
  290 |     bool operator==(const handle &h) const { return m_ptr == h.m_ptr; }
      |          ^~~~~~~~
```

PiperOrigin-RevId: 555974032
parent 6c3bd789
......@@ -191,7 +191,7 @@ struct type_caster<absl::Duration> {
return false;
}
auto py_duration_t = module::import("datetime").attr("timedelta");
if (src == object(py_duration_t.attr("max"))) {
if (src.is(py_duration_t.attr("max"))) {
value = absl::InfiniteDuration();
} else {
value = absl::Hours(24 * GetInt64Attr(src, "days")) +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment