]> granicus.if.org Git - python/commitdiff
asyncio: Fix _ProactorBasePipeTransport.__repr__()
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 15 Jan 2015 12:32:28 +0000 (13:32 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 15 Jan 2015 12:32:28 +0000 (13:32 +0100)
Check if the _sock attribute is None to check if the transport is closed.

Lib/asyncio/proactor_events.py

index 0ecb44eb360cfd66f737ccff5b87a00d86773a99..a177d32af6ed6df0a10fc6d3bd60917270e59681 100644 (file)
@@ -43,12 +43,12 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin,
 
     def __repr__(self):
         info = [self.__class__.__name__]
-        fd = self._sock.fileno()
-        if fd < 0:
+        if self._sock is None:
             info.append('closed')
         elif self._closing:
             info.append('closing')
-        info.append('fd=%s' % fd)
+        if self._sock is not None:
+            info.append('fd=%s' % self._sock.fileno())
         if self._read_fut is not None:
             info.append('read=%s' % self._read_fut)
         if self._write_fut is not None: