Commits

carandraug committed 28ed0b6

Do not check for result type in CheckContext.Result, support duck typing

Comments (0)

Files changed (1)

src/engine/SCons/SConf.py

 import re
 import sys
 import traceback
-import types
 
 import SCons.Action
 import SCons.Builder
         self.did_show_result = 0
 
     def Result(self, res):
-        """Inform about the result of the test. res may be an integer, a
-        string, or a boolean. In case of an integer, the written text will be
-        'yes' or 'no'. The result is only displayed when self.did_show_result
-        is not set.
+        """Inform about the result of the test. If res is not a string, displays
+        'yes' or 'no' depending on whether res is evaluated as true or false.
+        The result is only displayed when self.did_show_result is not set.
         """
-        if isinstance(res, (int, bool, types.NoneType)):
-            if res:
-                text = "yes"
-            else:
-                text = "no"
-        elif isinstance(res, str):
+        if isinstance(res, str):
             text = res
+        elif res:
+            text = "yes"
         else:
-            raise TypeError("Expected string, int or bool, got " + str(type(res)))
+            text = "no"
 
         if self.did_show_result == 0:
             # Didn't show result yet, do it now.