From a50f6e2e1e8b4610adde709079bec17ad0944197 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 21 Oct 2024 22:46:08 +0100 Subject: [PATCH] Fix _static.Dict.__ior__ for Python 3.8 --- setuptools/_static.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setuptools/_static.py b/setuptools/_static.py index 901e72c1e6..4ddac2c08e 100644 --- a/setuptools/_static.py +++ b/setuptools/_static.py @@ -24,7 +24,7 @@ class Static: _mutated_: bool = False # TODO: Remove after deprecation warning is solved -def _prevent_modification(target: type, method: str, copying: str): +def _prevent_modification(target: type, method: str, copying: str) -> None: """ Because setuptools is very flexible we cannot fully prevent plugins and user customisations from modifying static values that were @@ -32,7 +32,9 @@ def _prevent_modification(target: type, method: str, copying: str): But we can attempt to block "in-place" mutations and identify when they were done. """ - fn = getattr(target, method) + fn = getattr(target, method, None) + if fn is None: + return @wraps(fn) def _replacement(self: Static, *args, **kwargs):