Skip to content

Commit

Permalink
Resolve pybind11 deprecation warning.
Browse files Browse the repository at this point in the history
Observed while locally testing #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
  • Loading branch information
Ralf W. Grosse-Kunstleve authored and copybara-github committed Aug 11, 2023
1 parent 6c3bd78 commit e01527c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pybind11_abseil/absl_casters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")) +
Expand Down

0 comments on commit e01527c

Please sign in to comment.