From 6c7365148fd16f63be8083785f1e43194e22d3c4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 3 Apr 2025 22:38:14 -0700 Subject: [PATCH] gh-118761: Defer import of functools in annotationlib --- Lib/annotationlib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/annotationlib.py b/Lib/annotationlib.py index c08cd4d66589b6..c42dad3503bff7 100644 --- a/Lib/annotationlib.py +++ b/Lib/annotationlib.py @@ -3,7 +3,6 @@ import ast import builtins import enum -import functools import keyword import sys import types @@ -765,9 +764,10 @@ def get_annotations( if hasattr(unwrap, "__wrapped__"): unwrap = unwrap.__wrapped__ continue - if isinstance(unwrap, functools.partial): - unwrap = unwrap.func - continue + if functools := sys.modules.get("functools"): + if isinstance(unwrap, functools.partial): + unwrap = unwrap.func + continue break if hasattr(unwrap, "__globals__"): obj_globals = unwrap.__globals__ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy