Skip to content

Commit 9212f66

Browse files
committed
# This is a combination of 3 commits.
# This is the 1st commit message: Updated SSL.py to fix problem caused by SSL_WANT_READ or SSL_WANT_WRITE errors. When SSL_WANT_READ or SSL_WANT_WRITE are encountered, it's typical to retry the call but this must be repeated with the exact same arguments. Without this change, openSSL requires that the address of the buffer passed is the same. However, buffers in python can change location in some circumstances which cause the retry to fail. By add the setting SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, the requirement for the same buffer address is forgiven and the retry has a better chance of success. See cherrypy/cheroot#245 for discussion. # This is the commit message pyca#2: fixed format for flake8/black # This is the commit message pyca#3: E721 errors raised by flake8
1 parent 7f3e4f9 commit 9212f66

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/OpenSSL/SSL.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,10 @@ def __init__(self, method):
865865
self._cookie_generate_helper = None
866866
self._cookie_verify_helper = None
867867

868-
self.set_mode(_lib.SSL_MODE_ENABLE_PARTIAL_WRITE)
868+
self.set_mode(
869+
_lib.SSL_MODE_ENABLE_PARTIAL_WRITE
870+
| _lib.SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
871+
)
869872
if version is not None:
870873
self.set_min_proto_version(version)
871874
self.set_max_proto_version(version)

tests/test_crypto.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ def test_construction(self):
17401740
certificate = X509()
17411741
assert isinstance(certificate, X509)
17421742
assert type(certificate).__name__ == "X509"
1743-
assert type(certificate) == X509
1743+
assert type(certificate) is X509
17441744

17451745
def test_set_version_wrong_args(self):
17461746
"""
@@ -3148,7 +3148,7 @@ def test_construction(self):
31483148
"""
31493149
revoked = Revoked()
31503150
assert isinstance(revoked, Revoked)
3151-
assert type(revoked) == Revoked
3151+
assert type(revoked) is Revoked
31523152
assert revoked.get_serial() == b"00"
31533153
assert revoked.get_rev_date() is None
31543154
assert revoked.get_reason() is None
@@ -3443,8 +3443,8 @@ def test_get_revoked(self):
34433443

34443444
revs = crl.get_revoked()
34453445
assert len(revs) == 2
3446-
assert type(revs[0]) == Revoked
3447-
assert type(revs[1]) == Revoked
3446+
assert type(revs[0]) is Revoked
3447+
assert type(revs[1]) is Revoked
34483448
assert revs[0].get_serial() == b"03AB"
34493449
assert revs[1].get_serial() == b"0100"
34503450
assert revs[0].get_rev_date() == now

tests/test_ssl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def join_bytes_or_unicode(prefix, suffix):
190190
The return type is the same as the type of ``prefix``.
191191
"""
192192
# If the types are the same, nothing special is necessary.
193-
if type(prefix) == type(suffix):
193+
if type(prefix) is type(suffix):
194194
return join(prefix, suffix)
195195

196196
# Otherwise, coerce suffix to the type of prefix.

0 commit comments

Comments
 (0)