Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIMultiDict copy not working as expected #107

Closed
lsbardel opened this issue Jul 9, 2017 · 3 comments
Closed

CIMultiDict copy not working as expected #107

lsbardel opened this issue Jul 9, 2017 · 3 comments

Comments

@lsbardel
Copy link

lsbardel commented Jul 9, 2017

There is an issue with CIMultiDict copy method

import multidict
multidict.__version__  # '3.1.1'
a = multidict.CIMultiDict()
a['foo'] = 6
b = a.copy()
b['foo'] = 7
b # <CIMultiDict('foo': 7)>
a # <CIMultiDict('foo': 7)>

And using the copy function

import copy
c = copy.copy(a)

I get

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../venv/lib/python3.6/copy.py", line 106, in copy
    return _reconstruct(x, None, *rv)
  File ".../venv/lib/python3.6/copy.py", line 274, in _reconstruct
    y = func(*args)
  File "multidict/_multidict.pyx", line 531, in multidict._multidict.CIMultiDict.__init__ (multidict/_multidict.c:9519)
  File "multidict/_multidict.pyx", line 327, in multidict._multidict.MultiDict._extend (multidict/_multidict.c:6702)
TypeError: CIMultiDict takes either dict or list of (key, value) tuples
@lsbardel
Copy link
Author

lsbardel commented Jul 9, 2017

Copy initialisation has issues too (all related I assume):

a = multidict.CIMultiDict(foo=6)
b = multidict.CIMultiDict(a)
b['foo'] = 7
b # <CIMultiDict('foo': 7)>
a # <CIMultiDict('foo': 7)>

but this works OK

a = multidict.CIMultiDict(foo=6)
b = multidict.CIMultiDict(a.items())
b['foo'] = 7
b # <CIMultiDict('foo': 7)>
a # <CIMultiDict('foo': 6)>

@asvetlov
Copy link
Member

asvetlov commented Jul 9, 2017

Thanks for report!

@asvetlov
Copy link
Member

Fixed by 3555d46 and 04e740d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants