Browse Source

strtobool(bool) now works

Ask Solem 13 years ago
parent
commit
a8480ca78c
1 changed files with 6 additions and 4 deletions
  1. 6 4
      celery/utils/__init__.py

+ 6 - 4
celery/utils/__init__.py

@@ -169,10 +169,12 @@ def maybe_reraise():
 def strtobool(term, table={"false": False, "no": False, "0": False,
                              "true":  True, "yes": True,  "1": True,
                              "on":    True, "off": False}):
-    try:
-        return table[term.lower()]
-    except KeyError:
-        raise TypeError("Can't coerce %r to type bool" % (term, ))
+    if isinstance(term, basestring):
+        try:
+            return table[term.lower()]
+        except KeyError:
+            raise TypeError("Can't coerce %r to type bool" % (term, ))
+    return term
 
 # ------------------------------------------------------------------------ #
 # > XXX Compat