From 2dca7a75eef7c931abbbb6b9a87b1659db5ae6c8 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 22 May 2020 11:32:07 -0500 Subject: Remove deprecated tsafe module. (#913) --- CHANGELOG.rst | 1 + src/OpenSSL/tsafe.py | 31 ------------------------------- tests/test_tsafe.py | 23 ----------------------- 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 src/OpenSSL/tsafe.py delete mode 100644 tests/test_tsafe.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f72d0a6..622369d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,7 @@ The third digit is only for regressions. Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Remove deprecated ``OpenSSL.tsafe`` module. - Drop support for Python 3.4 - Drop support for OpenSSL 1.0.1 diff --git a/src/OpenSSL/tsafe.py b/src/OpenSSL/tsafe.py deleted file mode 100644 index f1c6f67..0000000 --- a/src/OpenSSL/tsafe.py +++ /dev/null @@ -1,31 +0,0 @@ -import warnings -from threading import RLock as _RLock - -from OpenSSL import SSL as _ssl - - -warnings.warn( - "OpenSSL.tsafe is deprecated and will be removed", - DeprecationWarning, stacklevel=3 -) - - -class Connection: - def __init__(self, *args): - self._ssl_conn = _ssl.Connection(*args) - self._lock = _RLock() - - for f in ('get_context', 'pending', 'send', 'write', 'recv', 'read', - 'renegotiate', 'bind', 'listen', 'connect', 'accept', - 'setblocking', 'fileno', 'shutdown', 'close', 'get_cipher_list', - 'getpeername', 'getsockname', 'getsockopt', 'setsockopt', - 'makefile', 'get_app_data', 'set_app_data', 'state_string', - 'sock_shutdown', 'get_peer_certificate', 'get_peer_cert_chain', - 'want_read', 'want_write', 'set_connect_state', - 'set_accept_state', 'connect_ex', 'sendall'): - exec("""def %s(self, *args): - self._lock.acquire() - try: - return self._ssl_conn.%s(*args) - finally: - self._lock.release()\n""" % (f, f)) diff --git a/tests/test_tsafe.py b/tests/test_tsafe.py deleted file mode 100644 index 8ffe35a..0000000 --- a/tests/test_tsafe.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) Jean-Paul Calderone -# See LICENSE for details. - -""" -Unit tests for `OpenSSL.tsafe`. -""" - -from OpenSSL.SSL import TLSv1_METHOD, Context -from OpenSSL.tsafe import Connection - - -class TestConnection(object): - """ - Tests for `OpenSSL.tsafe.Connection`. - """ - def test_instantiation(self): - """ - `OpenSSL.tsafe.Connection` can be instantiated. - """ - # The following line should not throw an error. This isn't an ideal - # test. It would be great to refactor the other Connection tests so - # they could automatically be applied to this class too. - Connection(Context(TLSv1_METHOD), None) -- cgit v1.2.1