From 4d0968dea85116888ac5b1162a446b4c90c41791 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Thu, 5 Dec 2024 19:50:22 -0500 Subject: [PATCH] use getattr --- include/pybind11/pytypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 2b0f522e06..7ba991e06c 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -2572,7 +2572,7 @@ object object_api::annotations() const { // Python 3.8, 3.9 #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 9 if (isinstance(derived())) { - return getattr(derived(), "__dict__").get("__annotations__", dict()); + return getattr(getattr(derived(), "__dict__"), "__annotations__", dict()); } else { return getattr(derived(), "__annotations__", dict()); }