Commits

Anonymous committed 4a2c3ae

The Grande 'sendall()' patch. I believe that I've picked up everything
in the std lib that should be using sendall(), rather than send() - I've
tried to check each of the patches.

Replaces calls to socket.send() (which isn't guaranteed to send all data)
with the new socket.sendall() method.

  • Participants
  • Parent commits e69b21f
  • Branches 2.1

Comments (0)

Files changed (9)

File Lib/ftplib.py

     def putline(self, line):
         line = line + CRLF
         if self.debugging > 1: print '*put*', self.sanitize(line)
-        self.sock.send(line)
+        self.sock.sendall(line)
 
     # Internal: send one command to the server (through putline())
     def putcmd(self, line):
         tried.  Instead, just send the ABOR command as OOB data.'''
         line = 'ABOR' + CRLF
         if self.debugging > 1: print '*put urgent*', self.sanitize(line)
-        self.sock.send(line, MSG_OOB)
+        self.sock.sendall(line, MSG_OOB)
         resp = self.getmultiline()
         if resp[:3] not in ('426', '226'):
             raise error_proto, resp
         while 1:
             buf = fp.read(blocksize)
             if not buf: break
-            conn.send(buf)
+            conn.sendall(buf)
         conn.close()
         return self.voidresp()
 
             if buf[-2:] != CRLF:
                 if buf[-1] in CRLF: buf = buf[:-1]
                 buf = buf + CRLF
-            conn.send(buf)
+            conn.sendall(buf)
         conn.close()
         return self.voidresp()
 

File Lib/gopherlib.py

         port = int(port)
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.connect((host, port))
-    s.send(selector + CRLF)
+    s.sendall(selector + CRLF)
     s.shutdown(1)
     return s.makefile('rb')
 

File Lib/httplib.py

         if self.debuglevel > 0:
             print "send:", repr(str)
         try:
-            self.sock.send(str)
+            self.sock.sendall(str)
         except socket.error, v:
             if v[0] == 32:      # Broken pipe
                 self.close()

File Lib/imaplib.py

                 _log('> %s' % data)
 
         try:
-            self.sock.send('%s%s' % (data, CRLF))
+            self.sock.sendall('%s%s' % (data, CRLF))
         except socket.error, val:
             raise self.abort('socket error: %s' % val)
 
                     _mesg('write literal size %s' % len(literal))
 
             try:
-                self.sock.send(literal)
-                self.sock.send(CRLF)
+                self.sock.sendall(literal)
+                self.sock.sendall(CRLF)
             except socket.error, val:
                 raise self.abort('socket error: %s' % val)
 

File Lib/nntplib.py

         """Internal: send one line to the server, appending CRLF."""
         line = line + CRLF
         if self.debugging > 1: print '*put*', `line`
-        self.sock.send(line)
+        self.sock.sendall(line)
 
     def putcmd(self, line):
         """Internal: send one command to the server (through putline())."""

File Lib/poplib.py

 
     def _putline(self, line):
         #if self._debugging > 1: print '*put*', `line`
-        self.sock.send('%s%s' % (line, CRLF))
+        self.sock.sendall('%s%s' % (line, CRLF))
 
 
     # Internal: send one command to the server (through _putline())

File Lib/smtplib.py

         if self.debuglevel > 0: print 'send:', `str`
         if self.sock:
             try:
-                sendptr = 0
-                while sendptr < len(str):
-                    sendptr = sendptr + self.sock.send(str[sendptr:])
+                self.sock.sendall(str)
             except socket.error:
                 raise SMTPServerDisconnected('Server not connected')
         else:

File Lib/socket.py

 
     def flush(self):
         if self._wbuf:
-            self._sock.send(self._wbuf)
+            self._sock.sendall(self._wbuf)
             self._wbuf = ""
 
     def fileno(self):
                 self.flush()
 
     def writelines(self, list):
-        filter(self._sock.send, list)
+        filter(self._sock.sendall, list)
         self.flush()
 
     def read(self, n=-1):

File Lib/telnetlib.py

         if IAC in buffer:
             buffer = buffer.replace(IAC, IAC+IAC)
         self.msg("send %s", `buffer`)
-        self.sock.send(buffer)
+        self.sock.sendall(buffer)
 
     def read_until(self, match, timeout=None):
         """Read until a given string is encountered or until timeout.
                 elif c in (DO, DONT):
                     opt = self.rawq_getchar()
                     self.msg('IAC %s %d', c == DO and 'DO' or 'DONT', ord(c))
-                    self.sock.send(IAC + WONT + opt)
+                    self.sock.sendall(IAC + WONT + opt)
                 elif c in (WILL, WONT):
                     opt = self.rawq_getchar()
                     self.msg('IAC %s %d',
                              c == WILL and 'WILL' or 'WONT', ord(c))
-                    self.sock.send(IAC + DONT + opt)
+                    self.sock.sendall(IAC + DONT + opt)
                 else:
                     self.msg('IAC %s not recognized' % `c`)
         except EOFError: # raised by self.rawq_getchar()