- if self.api.config.PLC_API_DEBUG:
- self.log(0, runtime, *args)
-
- return result
+ # legacy code cannot be type-checked, due to the way Method.args() works
+ # as of 5.0-rc16 we don't use skip_type_check anymore
+ if not hasattr(self,"skip_type_check"):
+ (min_args, max_args, defaults) = self.args()
+
+ # Check that the right number of arguments were passed in
+ if len(args) < len(min_args) or len(args) > len(max_args):
+ raise PLCInvalidArgumentCount(len(args), len(min_args), len(max_args))
+
+ for name, value, expected in zip(max_args, args, self.accepts):
+ self.type_check(name, value, expected, args)
+
+ result = self.call(*args, **kwds)
+ runtime = time.time() - start
+
+ if self.api.config.PLC_API_DEBUG or hasattr(self, 'message'):
+ self.log(None, runtime, *args)
+
+ return result