From: Ben Darnell Date: Mon, 1 Sep 2014 03:33:28 +0000 (-0400) Subject: Fix an erroneous return of None in IOStream.connect. X-Git-Tag: v4.0.2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39fd0eee635b082826995d3f7ee047c0c1be510a;p=thirdparty%2Ftornado.git Fix an erroneous return of None in IOStream.connect. This causes AttributeErrors in TCPClient, although I can only reproduce this case reliably on freebsd. Closes #1168. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index 99c681d80..1cc39d9fa 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -993,6 +993,11 @@ class IOStream(BaseIOStream): """ self._connecting = True + if callback is not None: + self._connect_callback = stack_context.wrap(callback) + future = None + else: + future = self._connect_future = TracebackFuture() try: self.socket.connect(address) except socket.error as e: @@ -1008,12 +1013,7 @@ class IOStream(BaseIOStream): gen_log.warning("Connect error on fd %s: %s", self.socket.fileno(), e) self.close(exc_info=True) - return - if callback is not None: - self._connect_callback = stack_context.wrap(callback) - future = None - else: - future = self._connect_future = TracebackFuture() + return future self._add_io_state(self.io_loop.WRITE) return future