Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch:
Changeset: r96678:aeb506f08f30
Date: 2019-05-25 11:39 +0200
http://bitbucket.org/pypy/pypy/changeset/aeb506f08f30/
Log: merge heads
diff --git a/lib-python/2.7/socket.py b/lib-python/2.7/socket.py
--- a/lib-python/2.7/socket.py
+++ b/lib-python/2.7/socket.py
@@ -61,20 +61,22 @@
DeprecationWarning, stacklevel=2)
return _realssl.sslwrap_simple(sock, keyfile, certfile)
- # we need to import the same constants we used to...
- from _ssl import SSLError as sslerror
- from _ssl import \
- RAND_add, \
- RAND_status, \
- SSL_ERROR_ZERO_RETURN, \
- SSL_ERROR_WANT_READ, \
- SSL_ERROR_WANT_WRITE, \
- SSL_ERROR_WANT_X509_LOOKUP, \
- SSL_ERROR_SYSCALL, \
- SSL_ERROR_SSL, \
- SSL_ERROR_WANT_CONNECT, \
- SSL_ERROR_EOF, \
- SSL_ERROR_INVALID_ERROR_CODE
+ # we need to import the same constants we used to,
+ # see lib_pypy/_cffi_ssl/_stdssl/error.py and __init__.py to prevent
+ # circular import
+ # from _ssl import SSLError as sslerror
+ # from _ssl import \
+ # RAND_add, \
+ # RAND_status
+ # SSL_ERROR_ZERO_RETURN, \
+ # SSL_ERROR_WANT_READ, \
+ # SSL_ERROR_WANT_WRITE, \
+ # SSL_ERROR_WANT_X509_LOOKUP, \
+ # SSL_ERROR_SYSCALL, \
+ # SSL_ERROR_SSL, \
+ # SSL_ERROR_WANT_CONNECT, \
+ # SSL_ERROR_EOF, \
+ # SSL_ERROR_INVALID_ERROR_CODE
try:
from _ssl import RAND_egd
except ImportError:
diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -20,6 +20,7 @@
pyerr_write_unraisable)
from _cffi_ssl._stdssl import error
from select import select
+import socket
if sys.platform == 'win32':
from _cffi_ssl._stdssl.win32_extra import enum_certificates, enum_crls
@@ -306,9 +307,6 @@
return self.socket_type == SSL_SERVER
def do_handshake(self):
- # delay to prevent circular imports
- import socket
-
sock = self.get_socket_or_connection_gone()
ssl = self.ssl
timeout = _socket_timeout(sock)
@@ -372,9 +370,6 @@
return _decode_certificate(self.peer_cert)
def write(self, bytestring):
- # delay to prevent circular imports
- import socket
-
deadline = 0
b = _str_to_ffi_buffer(bytestring)
sock = self.get_socket_or_connection_gone()
@@ -425,9 +420,6 @@
raise pyssl_error(self, length)
def read(self, length, buffer_into=None):
- # delay to prevent circular imports
- import socket
-
ssl = self.ssl
if length < 0 and buffer_into is None:
@@ -561,9 +553,6 @@
return sock
def shutdown(self):
- # delay to prevent circular imports
- import socket
-
sock = self.get_socket_or_None()
nonblocking = False
ssl = self.ssl
@@ -1545,3 +1534,5 @@
"enough data to seed the PRNG");
return bytecount
+socket.RAND_add = RAND_add
+socket.RAND_status = RAND_status
diff --git a/lib_pypy/_cffi_ssl/_stdssl/error.py
b/lib_pypy/_cffi_ssl/_stdssl/error.py
--- a/lib_pypy/_cffi_ssl/_stdssl/error.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/error.py
@@ -27,6 +27,13 @@
if self.strerror and isinstance(self.strerror, str):
return self.strerror
return str(self.args)
+# these are expected on socket as well
+socket.sslerror = SSLError
+for v in [ 'SSL_ERROR_ZERO_RETURN', 'SSL_ERROR_WANT_READ',
+ 'SSL_ERROR_WANT_WRITE', 'SSL_ERROR_WANT_X509_LOOKUP', 'SSL_ERROR_SYSCALL',
+ 'SSL_ERROR_SSL', 'SSL_ERROR_WANT_CONNECT', 'SSL_ERROR_EOF',
+ 'SSL_ERROR_INVALID_ERROR_CODE' ]:
+ setattr(socket, v, locals()[v])
class SSLZeroReturnError(SSLError):
""" SSL/TLS session closed cleanly. """
diff --git a/lib_pypy/_hashlib/__init__.py b/lib_pypy/_hashlib/__init__.py
--- a/lib_pypy/_hashlib/__init__.py
+++ b/lib_pypy/_hashlib/__init__.py
@@ -57,7 +57,7 @@
def update(self, string):
if isinstance(string, unicode):
- buf = ffi.from_buffer(string.encode('utf-8'))
+ buf = ffi.from_buffer(string.encode('ascii'))
else:
buf = ffi.from_buffer(string)
with self.lock:
diff --git a/pypy/module/_md5/test/test_md5.py
b/pypy/module/_md5/test/test_md5.py
--- a/pypy/module/_md5/test/test_md5.py
+++ b/pypy/module/_md5/test/test_md5.py
@@ -24,7 +24,8 @@
assert self.md5.md5().digest_size == 16
if sys.version_info >= (2, 5):
assert self.md5.blocksize == 1
- assert self.md5.md5().digestsize == 16
+ # implementation detail, not part of the API
+ # assert self.md5.md5().digestsize == 16
def test_MD5Type(self):
"""
diff --git a/pypy/module/_sha/test/test_sha.py
b/pypy/module/_sha/test/test_sha.py
--- a/pypy/module/_sha/test/test_sha.py
+++ b/pypy/module/_sha/test/test_sha.py
@@ -23,7 +23,8 @@
assert self.sha.digestsize == 20
d = self.sha.sha()
assert d.digest_size == 20
- assert d.digestsize == 20
+ # implementation detail, not part of the API
+ # assert d.digestsize == 20
def test_SHAType(self):
"""
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit