Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bank/btypes.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/bank/btypes.py b/bank/btypes.py
index d889920..34fd416 100644
--- a/bank/btypes.py
+++ b/bank/btypes.py
@@ -50,7 +50,9 @@ class Callable(object):
repo.TYPE_TAG_INT16,
repo.TYPE_TAG_UINT16,
repo.TYPE_TAG_INT32):
- if not isinstance(value, int):
+ try:
+ int(value)
+ except ValueError:
raise TypeError("%s must be int, not %s" % (name, type(value).__name__))
if tag in (repo.TYPE_TAG_UINT,
repo.TYPE_TAG_UINT8,
@@ -60,7 +62,9 @@ class Callable(object):
repo.TYPE_TAG_INT64,
repo.TYPE_TAG_UINT64,
repo.TYPE_TAG_ULONG):
- if not isinstance(value, (int, long)):
+ try:
+ long(value)
+ except ValueError:
raise TypeError("%s must be int or long, not %s" % (name, type(value).__name__))
if tag in (repo.TYPE_TAG_UINT32,
repo.TYPE_TAG_UINT64,
@@ -68,13 +72,17 @@ class Callable(object):
raise TypeError("%s must be an unsigned value, not %s", name, value)
elif tag in (repo.TYPE_TAG_FLOAT,
repo.TYPE_TAG_DOUBLE):
- if not isinstance(value, float):
+ try:
+ float(value)
+ except ValueError:
raise TypeError("%s must be float, not %s" % (name, type(value).__name__))
elif tag == repo.TYPE_TAG_INTERFACE:
# TODO
pass
elif tag == repo.TYPE_TAG_BOOLEAN:
- if not isinstance(value, bool):
+ try:
+ bool(value)
+ except ValueError:
raise TypeError("%s must be bool, not %s" % (name, type(value).__name__))
elif tag == repo.TYPE_TAG_ARRAY:
if value is not None: