[pypy-dev] gateway.applevel and kwargs

Leonardo Soto leo.soto at gmail.com
Sun Jul 30 03:11:14 CEST 2006


Hi all,

I've recently filled the issue 244 (dict.update() doesn't support
keywords argument), and tried to solve it in a naive way, just
modifying the applevel  definition to:

    def update(d, o, **kwargs):
        if hasattr(o, 'keys'):
            for k in o.keys():
                d[k] = o[k]
        else:
            for k,v in o:
                d[k] = v
        for k in kwargs:
            d[k] = kwargs[k]

But it simply doesn't work:

test_dictobject.py[34] .......................FF.........

__________________________________________________________________________________________________________________________________________
__________________________________________ entrypoint:
AppTest_DictObject().test_update_kwargs
___________________________________________

    def test_update_kwargs(self):
        d = {}
E       d.update(foo='bar', baz=1)
>       (application-level) TypeError: update() got 2 unexpected keyword arguments

[/home/leo/src/pypy-dist/pypy/objspace/std/test/None</home/leo/src/pypy-dist/pypy/interpreter/gateway.py:754>:3]
__________________________________________________________________________________________________________________________________________
______________________________________ entrypoint:
AppTest_DictObject().test_update_dict_and_kwargs
______________________________________

    def test_update_dict_and_kwargs(self):
        d = {}
E       d.update({'foo': 'bar'}, baz=1)
>       (application-level) TypeError: update() got an unexpected keyword argument 'baz'

[/home/leo/src/pypy-dist/pypy/objspace/std/test/None</home/leo/src/pypy-dist/pypy/interpreter/gateway.py:754>:3]

Why?. Should it work or is the lack of kwargs support a known limitation?

-- 
Leonardo Soto M.



More information about the Pypy-dev mailing list