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.1.0b1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15c82cbe20013873119148aabcdf2f53db4648ae;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 94fbb9476..ae4bc3d78 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