Skip to content

Commit 3555d46

Browse files
committed
Fix multidict construction
1 parent 3f190dc commit 3555d46

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
3.2.0 (2017-09-16)
1+
3.2.0 (2017-09-xx)
22
------------------
33

44
* Fix pickling (#134)

multidict/_multidict.pyx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,7 @@ cdef class MultiDict(_Base):
293293

294294
if args:
295295
arg = args[0]
296-
if isinstance(arg, CIMultiDict):
297-
self._impl._items.extend((<_Base>arg)._impl._items)
298-
elif isinstance(arg, _Base):
296+
if isinstance(arg, _Base):
299297
for i in (<_Base>arg)._impl._items:
300298
item = <_Pair>i
301299
key = item._key
@@ -387,8 +385,9 @@ cdef class MultiDict(_Base):
387385

388386
def copy(self):
389387
"""Return a copy of itself."""
390-
cls = self.__class__
391-
return cls(self)
388+
ret = MultiDict()
389+
ret._extend((list(self.items()),), {}, 'copy', True)
390+
return ret
392391

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

529528
def __init__(self, *args, **kwargs):
530529
self._impl = _Impl()
531-
532530
self._extend(args, kwargs, 'CIMultiDict', True)
533531

534532
def __reduce__(self):
@@ -545,6 +543,13 @@ cdef class CIMultiDict(MultiDict):
545543
return PyObject_Str(s)
546544
return s.title()
547545

546+
def copy(self):
547+
"""Return a copy of itself."""
548+
ret = CIMultiDict()
549+
ret._extend((list(self.items()),), {}, 'copy', True)
550+
return ret
551+
552+
548553

549554
abc.MutableMapping.register(CIMultiDict)
550555

0 commit comments

Comments
 (0)