From: Ben Darnell Date: Sat, 22 Dec 2012 17:08:03 +0000 (-0500) Subject: Allow tuples for the IOStream.close exc_info argument. X-Git-Tag: v3.0.0~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=800ebbf066173d9873907d763dec8c4fce8143ad;p=thirdparty%2Ftornado.git Allow tuples for the IOStream.close exc_info argument. Update release notes. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index 4c2f0d522..6eec2a357 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -212,12 +212,16 @@ class BaseIOStream(object): def close(self, exc_info=False): """Close this stream. - If `exc_info` is true, set the `error` attribute to the current - exception from ``sys.exc_info()``. + If ``exc_info`` is true, set the ``error`` attribute to the current + exception from `sys.exc_info()` (or if ``exc_info`` is a tuple, + use that instead of `sys.exc_info`). """ if not self.closed(): - if exc_info and any(sys.exc_info()): - self.error = sys.exc_info()[1] + if exc_info: + if not isinstance(exc_info, tuple): + exc_info = sys.exc_info() + if any(exc_info): + self.error = exc_info[1] if self._read_until_close: callback = self._read_callback self._read_callback = None diff --git a/website/sphinx/releases/next.rst b/website/sphinx/releases/next.rst index 5a07cf613..465572ded 100644 --- a/website/sphinx/releases/next.rst +++ b/website/sphinx/releases/next.rst @@ -204,3 +204,7 @@ In progress `Application.add_handlers` call. Now the request will be matched against the handlers for any ``host_pattern`` that includes the request's ``Host`` header. +* `IOStream.error` no longer picks up unrelated exceptions. +* `IOStream.close` now has an ``exc_info`` argument (similar to the + one used in the `logging` module) that can be used to set the stream's + ``error`` attribute when closing it.