[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.

e.g.

>>> 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}
>>>

Cheers,
Richard.

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list