]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The Grande 'sendall()' patch. I believe that I've picked up everything
authorAnthony Baxter <anthonybaxter@gmail.com>
Sun, 23 Dec 2001 01:47:10 +0000 (01:47 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Sun, 23 Dec 2001 01:47:10 +0000 (01:47 +0000)
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.

Lib/ftplib.py
Lib/gopherlib.py
Lib/httplib.py
Lib/imaplib.py
Lib/nntplib.py
Lib/poplib.py
Lib/smtplib.py
Lib/socket.py
Lib/telnetlib.py

index c08ad45cb563dba772b133e6d1fd4daeb8a3436e..f2e90dc2c57de1e72f643e4477e1599c18bac291 100644 (file)
@@ -155,7 +155,7 @@ class FTP:
     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):
@@ -218,7 +218,7 @@ class FTP:
         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
@@ -372,7 +372,7 @@ class FTP:
         while 1:
             buf = fp.read(blocksize)
             if not buf: break
-            conn.send(buf)
+            conn.sendall(buf)
         conn.close()
         return self.voidresp()
 
@@ -386,7 +386,7 @@ class FTP:
             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()
 
index f5bbca52b741e99f3cd8e7a396d7443ba2271a22..7d188982f7ce9d0254ecccf8e038ddd969468329 100644 (file)
@@ -66,7 +66,7 @@ def send_selector(selector, host, port = 0):
         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')
 
index 1e08539e2fece0fd02324fbe35859f15f8ddc4fa..0ca65db324d80667e76b38a2472a904526d0aab1 100644 (file)
@@ -388,7 +388,7 @@ class HTTPConnection:
         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()
index 26faa9eba10da294a4110f3fbf8d5658c0ad4ecb..7186114b7c58ac065fe2f24010adaf8e36bc73cd 100644 (file)
@@ -633,7 +633,7 @@ class IMAP4:
                 _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)
 
@@ -657,8 +657,8 @@ class IMAP4:
                     _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)
 
index d97813fed4b1d877872d2c562dcaa9f8d8a6d818..a2344f619f45cf739a00c5f615c88b4e45d4206d 100644 (file)
@@ -178,7 +178,7 @@ class NNTP:
         """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())."""
index fb24a0f9c5b83c655d305ea31178426a87ede990..da20f6667fe414b5258d3ad895d61373c5e621e8 100644 (file)
@@ -84,7 +84,7 @@ class POP3:
 
     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())
index f1e4a27ff3bfd7b7aca47ca6e9925efb03ab8077..d01641662f2d5bd45c1e1c752758a6b2c72d80c3 100755 (executable)
@@ -232,9 +232,7 @@ class SMTP:
         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:
index 54b4b8710f475c5762c05cbaf2453eddf68beef2..7cb24e808386a36ced1c4a706cb348a5b073e0ea 100644 (file)
@@ -176,7 +176,7 @@ class _fileobject:
 
     def flush(self):
         if self._wbuf:
-            self._sock.send(self._wbuf)
+            self._sock.sendall(self._wbuf)
             self._wbuf = ""
 
     def fileno(self):
@@ -192,7 +192,7 @@ class _fileobject:
                 self.flush()
 
     def writelines(self, list):
-        filter(self._sock.send, list)
+        filter(self._sock.sendall, list)
         self.flush()
 
     def read(self, n=-1):
index 6b249e8db416f26d7f2e597022b10ed9a1578319..70026f04900835ad52562aac58ff583bd18d6db2 100644 (file)
@@ -190,7 +190,7 @@ class Telnet:
         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.
@@ -325,12 +325,12 @@ class Telnet:
                 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()