From 52773da0faddc808056ffec34ed0112e2b42b5f7 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Fri, 15 May 2020 23:31:41 -0400 Subject: use signature to check function signature instead of relying on TypeErrors --- SCons/Subst.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SCons/Subst.py b/SCons/Subst.py index a1ef053..29698d5 100644 --- a/SCons/Subst.py +++ b/SCons/Subst.py @@ -30,7 +30,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import collections import re - +from inspect import signature import SCons.Errors from SCons.Util import is_String, is_Sequence @@ -420,12 +420,13 @@ class StringSubber(object): return conv(substitute(l, lvars)) return list(map(func, s)) elif callable(s): - try: + if (s and + set(signature(s).parameters.keys()) == set(['target', 'source', 'env', 'for_signature'])): s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], env=self.env, for_signature=(self.mode != SUBST_CMD)) - except TypeError: + else: # This probably indicates that it's a callable # object that doesn't match our calling arguments # (like an Action). -- cgit v0.12