Skip to content

Commit

Permalink
Fix multidict construction
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Sep 17, 2017
1 parent 3f190dc commit 3555d46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
3.2.0 (2017-09-16)
3.2.0 (2017-09-xx)
------------------

* Fix pickling (#134)
Expand Down
17 changes: 11 additions & 6 deletions multidict/_multidict.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ cdef class MultiDict(_Base):

if args:
arg = args[0]
if isinstance(arg, CIMultiDict):
self._impl._items.extend((<_Base>arg)._impl._items)
elif isinstance(arg, _Base):
if isinstance(arg, _Base):
for i in (<_Base>arg)._impl._items:
item = <_Pair>i
key = item._key
Expand Down Expand Up @@ -387,8 +385,9 @@ cdef class MultiDict(_Base):

def copy(self):
"""Return a copy of itself."""
cls = self.__class__
return cls(self)
ret = MultiDict()
ret._extend((list(self.items()),), {}, 'copy', True)
return ret

def extend(self, *args, **kwargs):
"""Extend current MultiDict with more values.
Expand Down Expand Up @@ -528,7 +527,6 @@ cdef class CIMultiDict(MultiDict):

def __init__(self, *args, **kwargs):
self._impl = _Impl()

self._extend(args, kwargs, 'CIMultiDict', True)

def __reduce__(self):
Expand All @@ -545,6 +543,13 @@ cdef class CIMultiDict(MultiDict):
return PyObject_Str(s)
return s.title()

def copy(self):
"""Return a copy of itself."""
ret = CIMultiDict()
ret._extend((list(self.items()),), {}, 'copy', True)
return ret



abc.MutableMapping.register(CIMultiDict)

Expand Down

0 comments on commit 3555d46

Please sign in to comment.