[Python-Dev] Very Strange Argument Handling Behavior
Raghuram Devarakonda
draghuram at gmail.com
Fri Apr 16 16:49:35 CEST 2010
On Fri, Apr 16, 2010 at 12:57 AM, Alex Gaynor <alex.gaynor at gmail.com> wrote:
> Hi all,
>
> I ran into the follow behavior while making sure Django works
> correctly on PyPy. The following behavior was observed in all tested
> versions of CPython (2.5, 3.1):
>
>>>> def f(**kwargs):
> ... print(kwargs)
> ...
>>>> kwargs = {1: 3}
>>>>
>>>> dict({}, **kwargs)
> {1: 3}
>>>> f(**kwargs)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: f() keywords must be strings
>>>>
>
>
> This behavior seems pretty strange to me, indeed PyPy gives the
> TypeError for both attempts. I just wanted to confirm that it was in
> fact intentional.
I ran into same issue with Django on Jython yesterday [1] since Jython
too gives TypeError for 'dict({}, **kwargs)'.
Thanks,
Raghu
[1] http://bugs.jython.org/issue1600
More information about the Python-Dev
mailing list