New issue 2435: Difference between PyPy and CPython when converting a subclass 
of dict to kwargs
https://bitbucket.org/pypy/pypy/issues/2435/difference-between-pypy-and-cpython-when

Mark Heppner:

In Django, there is a data structure called a 
[`MultiValueDict`](https://github.com/django/django/blob/1.10.3/django/utils/datastructures.py#L48)
 that subclasses off of `dict`. When converting it to kwargs, it behaves 
differently than CPython. I submitted a [ticket to 
Django](https://code.djangoproject.com/ticket/27521) that was closed pretty 
quickly.

An example using a 
[`QueryDict`](https://github.com/django/django/blob/1.10.3/django/http/request.py#L355):

```python
from django.conf import settings
settings.configure()
from django.http.request import QueryDict
q = QueryDict('foo=bar&foo=baz')

def test(**kwargs):
    print(kwargs)

test(**q)
```

In CPython, this returns `{u'foo': [u'bar', u'baz']}`, but in PyPy `{u'foo': 
u'baz'}` is returned. This only happens on conversion from the subclassed 
`dict` to kwargs.

I'm not sure if this is a bug or if the docs already [explain this 
behavior](http://doc.pypy.org/en/latest/cpython_differences.html#mutating-classes-of-objects-which-are-already-used-as-dictionary-keys).


_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to