Commit 8c9cf2e2 authored by Jason Madden's avatar Jason Madden

Make most of the tests pass again with the ssl279 code.

parent b6fcd5e4
...@@ -30,6 +30,7 @@ __imports__ = [] ...@@ -30,6 +30,7 @@ __imports__ = []
# Import all symbols from Python's ssl.py, except those that we are implementing # Import all symbols from Python's ssl.py, except those that we are implementing
# and "private" symbols. # and "private" symbols.
value = None
for name in dir(__ssl__): for name in dir(__ssl__):
if name in __implements__: if name in __implements__:
continue continue
...@@ -41,6 +42,11 @@ for name in dir(__ssl__): ...@@ -41,6 +42,11 @@ for name in dir(__ssl__):
del name, value del name, value
try:
_delegate_methods
except NameError: # PyPy doesn't expose this detail
_delegate_methods = ('recv', 'recvfrom', 'recv_into', 'recvfrom_into', 'send', 'sendto')
__all__ = __implements__ + __imports__ __all__ = __implements__ + __imports__
orig_SSLContext = __ssl__.SSLContext orig_SSLContext = __ssl__.SSLContext
...@@ -166,7 +172,6 @@ class SSLSocket(socket): ...@@ -166,7 +172,6 @@ class SSLSocket(socket):
server_hostname=None, server_hostname=None,
_context=None): _context=None):
self._makefile_refs = 0
if _context: if _context:
self._context = _context self._context = _context
else: else:
...@@ -197,7 +202,10 @@ class SSLSocket(socket): ...@@ -197,7 +202,10 @@ class SSLSocket(socket):
# mixed in. # mixed in.
if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM: if sock.getsockopt(SOL_SOCKET, SO_TYPE) != SOCK_STREAM:
raise NotImplementedError("only stream sockets are supported") raise NotImplementedError("only stream sockets are supported")
socket.__init__(self, _sock=sock._sock) socket.__init__(self, _sock=sock)
if PYPY:
sock._drop()
# The initializer for socket overrides the methods send(), recv(), etc. # The initializer for socket overrides the methods send(), recv(), etc.
# in the instancce, which we don't need -- but we want to provide the # in the instancce, which we don't need -- but we want to provide the
# methods defined in SSLSocket. # methods defined in SSLSocket.
...@@ -243,6 +251,8 @@ class SSLSocket(socket): ...@@ -243,6 +251,8 @@ class SSLSocket(socket):
except socket_error as x: except socket_error as x:
self.close() self.close()
raise x raise x
self._makefile_refs = 0
@property @property
def context(self): def context(self):
...@@ -469,6 +479,17 @@ class SSLSocket(socket): ...@@ -469,6 +479,17 @@ class SSLSocket(socket):
else: else:
self._makefile_refs -= 1 self._makefile_refs -= 1
if PYPY:
def _reuse(self):
self._makefile_refs += 1
def _drop(self):
if self._makefile_refs < 1:
self.close()
else:
self._makefile_refs -= 1
def _sslobj_shutdown(self): def _sslobj_shutdown(self):
while True: while True:
try: try:
...@@ -571,7 +592,7 @@ class SSLSocket(socket): ...@@ -571,7 +592,7 @@ class SSLSocket(socket):
"""Make and return a file-like object that """Make and return a file-like object that
works with the SSL connection. Just use the code works with the SSL connection. Just use the code
from the socket module.""" from the socket module."""
if not PYPY:
self._makefile_refs += 1 self._makefile_refs += 1
# close=True so as to decrement the reference count when done with # close=True so as to decrement the reference count when done with
# the file-like object. # the file-like object.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment