From 8b241f1727d54a6bbd0a4b61237aedafd0b5593f Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Thu, 19 Dec 2024 13:31:09 -0800 Subject: [PATCH] fix scope? --- include/pybind11/cast.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index f556c5ede..650fcac9e 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1366,6 +1366,9 @@ object object_or_cast(T &&o) { return pybind11::cast(std::forward(o)); } +// This is being used to get around the conflict with the deprecated str() function on object_api +typedef str py_str; + // Declared in pytypes.h: // Written here so make_caster can be used template @@ -1379,7 +1382,7 @@ obj_attr_accessor object_api::attr_with_type_hint(handle key) const { object ann = annotations(); object reinterpreted_key = reinterpret_borrow(key); if (ann.contains(reinterpreted_key)) { - throw std::runtime_error("__annotations__[\"" + std::string(str(reinterpreted_key)) + throw std::runtime_error("__annotations__[\"" + py_str(reinterpreted_key) + "\"] was set already."); } ann[key] = make_caster::name.text;