summaryrefslogtreecommitdiff
path: root/M2Crypto
diff options
context:
space:
mode:
authorMarcus Huewe <suse-tux@gmx.de>2018-03-02 15:30:09 +0100
committerMatěj Cepl <mcepl@cepl.eu>2018-03-04 14:26:22 +0100
commitf749f85db5a61ad4ee0a83d9424cc856ef76fcda (patch)
tree0ad6a7f54d6157d5ccfb18b853e93ff1374d4496 /M2Crypto
parentff96d066fa94eb05924c39f028c36ae51aa9d790 (diff)
downloadm2crypto-f749f85db5a61ad4ee0a83d9424cc856ef76fcda.tar.gz
Fix SSL.Connection.__del__
Without this change self.m2_ssl_free(self.ssl) is never called, because m2.bio_noclose is defined as "0". Hence, the if-condition is always false. This got broken in commit e2f707b172 ("SSL package: Port to python3"). Note that these testcases rely on the "fact" (or CPython implementation detail?) that "del s" calls s' __del__ method.
Diffstat (limited to 'M2Crypto')
-rw-r--r--M2Crypto/SSL/Connection.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/M2Crypto/SSL/Connection.py b/M2Crypto/SSL/Connection.py
index 8a40de2..376c34a 100644
--- a/M2Crypto/SSL/Connection.py
+++ b/M2Crypto/SSL/Connection.py
@@ -41,6 +41,7 @@ class Connection:
m2_bio_free = m2.bio_free
m2_ssl_free = m2.ssl_free
+ m2_bio_noclose = m2.bio_noclose
def __init__(self, ctx, sock=None, family=socket.AF_INET):
# type: (Context, socket.socket, int) -> None
@@ -80,10 +81,7 @@ class Connection:
self.m2_bio_free(self.sslbio)
if getattr(self, 'sockbio', None):
self.m2_bio_free(self.sockbio)
- # in __del__ method we have to check whether m2.bio_noclose
- # exists at all.
- if m2 is not None and m2.bio_noclose and \
- self.ssl_close_flag == m2.bio_noclose and \
+ if self.ssl_close_flag == self.m2_bio_noclose and \
getattr(self, 'ssl', None):
self.m2_ssl_free(self.ssl)
self.socket.close()