1.1 --- a/micropython/trans.py Sat May 09 03:21:15 2009 +0200
1.2 +++ b/micropython/trans.py Mon May 11 02:17:12 2009 +0200
1.3 @@ -701,6 +701,8 @@
1.4 ndefaults = len(target.defaults)
1.5 nargs_min = nargs_max - ndefaults
1.6
1.7 + # Visit each argument position and look for a supplied argument.
1.8 +
1.9 for i in range(ncontext, nargs_min):
1.10 if i not in employed_positions:
1.11 raise TranslateError(self.module.full_name(), node,
1.12 @@ -708,17 +710,32 @@
1.13
1.14 nargs = frame_pos
1.15
1.16 - if nargs > nargs_max and not target.has_star and not target.has_dstar:
1.17 + # Determine whether too many arguments have been given and how big
1.18 + # the frame should be.
1.19 +
1.20 + # For parameter lists with * or ** parameters, accept as many
1.21 + # arguments as are allowed or as many as we have.
1.22 +
1.23 + if target.has_star or target.has_dstar:
1.24 + frame_size = max(nargs, nargs_max)
1.25 +
1.26 + # For other parameter lists, only accept as many arguments as we are
1.27 + # allowed.
1.28 +
1.29 + elif nargs > nargs_max:
1.30 raise TranslateError(self.module.full_name(), node,
1.31 "Too many arguments for %r: need at most %d argument(s)." % (target.name, nargs_max))
1.32
1.33 + else:
1.34 + frame_size = nargs_max
1.35 +
1.36 # Where defaults are involved, put them into the frame.
1.37
1.38 self._generateCallFuncDefaultArgs(target, temp, nargs_min, nargs_max, employed_positions)
1.39
1.40 # Set the frame size.
1.41
1.42 - self._endCallFuncArgs(nargs_max)
1.43 + self._endCallFuncArgs(frame_size)
1.44
1.45 # Or generate instructions to do this at run-time.
1.46