[Stackless] Keyword args problem with class inherited from stackless channel

Richard Tew richard.m.tew at gmail.com
Mon Jun 11 22:10:24 CEST 2007

On 6/11/07, Aseem Mohanty <aseem at metaweb.com> wrote:
> On doing so I keep getting the error:
> TypeError: 'timeout' is an invalid keyword argument for this function
> ...
> Is there something strange in stackless.channel that does not treat kwargs properly?

Hi Aseem,

Yes.  The implementation of __new__ in the channel class parses the
arguments causing this problem.  You can work around it by wrapping it
and making sure the arguments you add are removed from args and kwargs
before it is called.


>>> import stackless
>>> class T(stackless.channel):
...     def __init__(self, *args, **kwargs):
...             print "__init__", args, kwargs
...             stackless.channel.__init__(self, *args, **kwargs)
...     def __new__(self, *args, **kwargs):
...             print "__new__", args, kwargs
...             if "timeout" in kwargs: del kwargs["timeout"]
...             return stackless.channel.__new__(self, *args, **kwargs)
>>> t = T()
__new__ () {}
__init__ () {}
>>> t = T(timeout=1)
__new__ () {'timeout': 1}
__init__ () {'timeout': 1}


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list