[pybank] Really fix subclass constructors
- From: Johan Dahlin <johan src gnome org>
- To: svn-commits-list gnome org
- Subject: [pybank] Really fix subclass constructors
- Date: Tue, 2 Jun 2009 10:44:57 -0400 (EDT)
commit 9c4532060358dd8aa853ae0581e6d21fb8f3e67f
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Mon May 11 14:13:37 2009 +0200
Really fix subclass constructors
---
bank/btypes.py | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/bank/btypes.py b/bank/btypes.py
index 64e00de..a07f5f4 100644
--- a/bank/btypes.py
+++ b/bank/btypes.py
@@ -86,7 +86,7 @@ class Callable(object):
raise NotImplementedError('type checking for tag %d' % tag)
def __call__(self, *args, **kwargs):
- print '__call__ %r' % (args,)
+ print '__call__ %r %r %r' % (self, args, self.call_type)
infoArgs = list(self.info.getArgs())
requiredArgs = 0
for arg in infoArgs:
@@ -94,8 +94,8 @@ class Callable(object):
if direct in [repo.DIRECTION_IN, repo.DIRECTION_INOUT]:
requiredArgs += 1
- is_method = self.info.isMethod() and not self.info.isConstructor()
- if self.call_type in [self.INSTANCE_METHOD, self.CLASS_METHOD]:
+ is_method = self.call_type in [self.INSTANCE_METHOD, self.CLASS_METHOD]
+ if is_method:
requiredArgs += 1
totalInArgs = len(args) + len(kwargs)
@@ -104,19 +104,16 @@ class Callable(object):
raise TypeError('%r requires %d arguments, passed %d instead.' % (
self, requiredArgs, totalInArgs))
- inArgs = []
for i, value in enumerate(args):
if not is_method or i > 0:
off = is_method and 1 or 0
- infoArg = infoArgs[i-off]
+ infoArg = infoArgs[i - off]
argType = infoArg.getType()
name = infoArg.getName()
self.type_check(name, value, argType)
- inArgs.append(value)
-
- print "invoke with args %r" % inArgs
- retval = self.info.invoke(*inArgs)
+ print "invoke with args %r" % (args,)
+ retval = self.info.invoke(*args)
if self.info.isConstructor():
if retval is None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]