[Python-Dev] RE: test_asynchat.py broken on Windows

Fredrik Lundh fredrik@pythonware.com
Tue, 30 Oct 2001 09:56:07 +0100


> [Jeremy Hylton]
> > I think there are at least three things wrong, depending on what you
> > count as wrong.

not sure jeremy gets mail sent to his sourceforge address,
but maybe someone else can explain how his recent patch
preserves the original behaviour.

after the patch, connect will always raise an exception unless
the error code is one of the three listed code.  before the patch,
it will not raise an exception if the connection succeeds during
the connect itself (i.e. if people use asyncore with blocking
sockets, or if they're using a hypothetical transport that can
do an immediate connect).

how about adding an "else:" before that last raise?

     def connect (self, address):
          self.connected = 0
!         # XXX why not use connect_ex?
!         try:
!             self.socket.connect (address)
!         except socket.error, why:
!             if why[0] in (EINPROGRESS, EALREADY, EWOULDBLOCK):
!                 return
!             else:
!                 raise socket.error, why
!         self.addr = address
!         self.connected = 1
!         self.handle_connect()
  
      def accept (self):
--- 302,313 ----
      def connect (self, address):
          self.connected = 0
!         err = self.socket.connect_ex(address)
!         if err in (EINPROGRESS, EALREADY, EWOULDBLOCK):
!             return
!         if err in (0, EISCONN):
!             self.addr = address
!             self.connected = 1
!             self.handle_connect()
!         raise socket.error, err
  
      def accept (self):