[pybank] Fix arg count check
- From: Johan Dahlin <johan src gnome org>
- To: svn-commits-list gnome org
- Subject: [pybank] Fix arg count check
- Date: Tue, 2 Jun 2009 10:44:07 -0400 (EDT)
commit 5a10a1d05c198fe8602c91398e4a8393c8e8a0da
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Fri May 8 12:27:01 2009 +0200
Fix arg count check
---
bank/btypes.py | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/bank/btypes.py b/bank/btypes.py
index a72c93a..8ee7fbb 100644
--- a/bank/btypes.py
+++ b/bank/btypes.py
@@ -83,7 +83,6 @@ class Callable(object):
def __call__(self, *args, **kwargs):
infoArgs = list(self.info.getArgs())
- totalInArgs = len(args) + len(kwargs)
requiredArgs = 0
for arg in infoArgs:
direct = arg.getDirection()
@@ -100,14 +99,13 @@ class Callable(object):
elif is_method:
obj = args[0]
elif self.call_type == self.CLASS_METHOD:
- requiredArgs += 1
- cls = args[0]
args = args[1:]
-
+
+ totalInArgs = len(args) + len(kwargs)
if totalInArgs != requiredArgs:
- raise TypeError('%r requires %d arguments' % (
- self, requiredArgs))
+ raise TypeError('%r requires %d arguments, passed %d instead.' % (
+ self, requiredArgs, totalInArgs))
inArgs = []
for i, value in enumerate(args):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]