Skip to content

Commit

Permalink
Don't clear current exception in multidict's __repr__ (cythonized ver…
Browse files Browse the repository at this point in the history
…sions) #410
  • Loading branch information
asvetlov committed Jun 13, 2015
1 parent 5bdcce7 commit 55dc13b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGES
=======

0.16.4 (06-13-2015)
-------------------

- Don't clear current exception in multidict's `__repr__` (cythonized
versions) #410

0.16.3 (05-30-2015)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This relies on each of the submodules having an __all__ variable.

__version__ = '0.16.3'
__version__ = '0.16.4'


from . import hdrs # noqa
Expand Down
5 changes: 4 additions & 1 deletion aiohttp/_multidict.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ cdef class _Base:
return _ValuesView.__new__(_ValuesView, self._items)

def __repr__(self):
body = ', '.join("'{}': {!r}".format(k, v) for k, v in self.items())
lst = []
for k, v in self._items:
lst.append("'{}': {!r}".format(k, v))
body = ', '.join(lst)
return '<{} {{{}}}>'.format(self.__class__.__name__, body)

def __richcmp__(self, other, op):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_multidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ def test_isdisjoint2(self):
d = self.make_dict([('key', 'value1')])
self.assertFalse(d.keys().isdisjoint({'key'}))

def test_clear_exception_issue_410(self):
d = self.make_dict()
try:
raise Exception
except Exception:
repr(d)
self.assertIsNotNone(sys.exc_info()[0])


class _MultiDictTests(_BaseTest):

Expand Down

0 comments on commit 55dc13b

Please sign in to comment.