if self.is_staticmethod and env.is_c_class_scope:
nfixed = 0
- self.self_in_stararg = True
+ self.self_in_stararg = True # FIXME: why for staticmethods?
self.entry.signature = sig = copy.copy(sig)
sig.fixed_arg_format = "*"
self.starstar_arg.entry.xdecref_cleanup = 0
code.put_gotref(self.starstar_arg.entry.cname)
- if self.self_in_stararg:
+ if self.self_in_stararg and not self.target.is_staticmethod:
# need to create a new tuple with 'self' inserted as first item
code.put("%s = PyTuple_New(PyTuple_GET_SIZE(%s)+1); if (unlikely(!%s)) " % (
self.star_arg.entry.cname,
print arg1
super().mystaticmethod(self, arg1 + 1)
+
+cdef class ArgsKwargs(object):
+ @staticmethod
+ def with_first_arg(arg1, *args, **kwargs):
+ """
+ >>> ArgsKwargs().with_first_arg(1, 2, 3, a=4, b=5)
+ (1, 'pos', 2, 3, ('a', 4), ('b', 5))
+ """
+ return (arg1, 'pos') + args + tuple(sorted(kwargs.items()))
+
+ @staticmethod
+ def only_args_kwargs(*args, **kwargs):
+ """
+ >>> ArgsKwargs().only_args_kwargs()
+ ()
+ >>> ArgsKwargs().only_args_kwargs(1, 2, a=3)
+ (1, 2, ('a', 3))
+ """
+ return args + tuple(sorted(kwargs.items()))