summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-14 14:37:18 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-14 14:37:18 (GMT)
commitf7f390a2510e91935a14e0b25a6c98d9278c962f (patch)
treecf3da6631912269fcf97d0c646c2b25cbe84a45f /Lib/ssl.py
parent7a84877de1bde4ae8c5ab81fd296a2d9a6f164dc (diff)
downloadcpython-f7f390a2510e91935a14e0b25a6c98d9278c962f.zip
cpython-f7f390a2510e91935a14e0b25a6c98d9278c962f.tar.gz
cpython-f7f390a2510e91935a14e0b25a6c98d9278c962f.tar.bz2
Issue #9729: Fix the signature of SSLSocket.recvfrom() and
SSLSocket.sendto() to match the corresponding socket methods. Also, fix various SSLSocket methods to raise socket.error rather than an unhelpful TypeError when called on an unconnected socket. Original patch by Andrew Bennetts. NOTE: obviously, these methods are untested and unused in the real world...
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 96b6281..8c2cdf1 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -184,14 +184,16 @@ class SSLSocket(socket):
else:
return v
else:
- return socket.send(self, data, flags)
+ return self._sock.send(data, flags)
- def sendto(self, data, addr, flags=0):
+ def sendto(self, data, flags_or_addr, addr=None):
if self._sslobj:
raise ValueError("sendto not allowed on instances of %s" %
self.__class__)
+ elif addr is None:
+ return self._sock.sendto(data, flags_or_addr)
else:
- return socket.sendto(self, data, addr, flags)
+ return self._sock.sendto(data, flags_or_addr, addr)
def sendall(self, data, flags=0):
if self._sslobj:
@@ -216,7 +218,7 @@ class SSLSocket(socket):
self.__class__)
return self.read(buflen)
else:
- return socket.recv(self, buflen, flags)
+ return self._sock.recv(buflen, flags)
def recv_into(self, buffer, nbytes=None, flags=0):
if buffer and (nbytes is None):
@@ -233,21 +235,21 @@ class SSLSocket(socket):
buffer[:v] = tmp_buffer
return v
else:
- return socket.recv_into(self, buffer, nbytes, flags)
+ return self._sock.recv_into(buffer, nbytes, flags)
- def recvfrom(self, addr, buflen=1024, flags=0):
+ def recvfrom(self, buflen=1024, flags=0):
if self._sslobj:
raise ValueError("recvfrom not allowed on instances of %s" %
self.__class__)
else:
- return socket.recvfrom(self, addr, buflen, flags)
+ return self._sock.recvfrom(buflen, flags)
def recvfrom_into(self, buffer, nbytes=None, flags=0):
if self._sslobj:
raise ValueError("recvfrom_into not allowed on instances of %s" %
self.__class__)
else:
- return socket.recvfrom_into(self, buffer, nbytes, flags)
+ return self._sock.recvfrom_into(buffer, nbytes, flags)
def pending(self):
if self._sslobj: