From c460740cbfbcfe13b565ee0429d23cdf71e57a09 Mon Sep 17 00:00:00 2001 From: manish0820 Date: Tue, 8 Sep 2026 12:48:28 +0530 Subject: [PATCH] fix(sessions): allow builtins.getattr in migration unpickler for py311 + crewai --- src/google/adk/sessions/_restricted_pickle.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/google/adk/sessions/_restricted_pickle.py b/src/google/adk/sessions/_restricted_pickle.py index 5dcaae39e0f..db25e636211 100644 --- a/src/google/adk/sessions/_restricted_pickle.py +++ b/src/google/adk/sessions/_restricted_pickle.py @@ -74,6 +74,15 @@ ("datetime", "time"), ("datetime", "timedelta"), ("datetime", "timezone"), + # CPython 3.11's `enum.py` pickles some Enum members via + # `pickle_by_enum_name`, whose `__reduce_ex__` returns + # `(getattr, (self.__class__, self._name_))` instead of the + # value-based reconstruction used on 3.10/3.12+. This is safe to allow + # unconditionally: `getattr`'s first argument is itself an enum class + # resolved through this same `find_class` allow-list check (via its own + # GLOBAL/STACK_GLOBAL opcode), so allowing the `getattr` callable here + # does not admit any class that wasn't already permitted. + ("builtins", "getattr"), ("decimal", "Decimal"), ("uuid", "UUID"), # Python 3.13 moved the concrete `pathlib` classes into a private