[Python-checkins] cpython (3.3): remove __del__ because it's evil and also prevents the ResourceWarning on the
benjamin.peterson
python-checkins at python.org
Thu Jan 10 21:17:00 CET 2013
http://hg.python.org/cpython/rev/c8105251cc1f
changeset: 81372:c8105251cc1f
branch: 3.3
parent: 81368:6a85894c428f
user: Benjamin Peterson <benjamin at python.org>
date: Thu Jan 10 14:16:20 2013 -0600
summary:
remove __del__ because it's evil and also prevents the ResourceWarning on the socket from happening (closes #16900)
files:
Lib/ssl.py | 4 ----
Lib/test/test_ssl.py | 8 ++++++++
Misc/NEWS | 2 ++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Lib/ssl.py b/Lib/ssl.py
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -574,10 +574,6 @@
return None
return self._sslobj.tls_unique_cb()
- def __del__(self):
- # sys.stderr.write("__del__ on %s\n" % repr(self))
- self._real_close()
-
def wrap_socket(sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -374,6 +374,14 @@
ss = ssl.wrap_socket(s, server_side=True, certfile=CERTFILE)
self.assertIsNone(ss.get_channel_binding("tls-unique"))
+ def test_dealloc_warn(self):
+ ss = ssl.wrap_socket(socket.socket(socket.AF_INET))
+ r = repr(ss)
+ with self.assertWarns(ResourceWarning) as cm:
+ ss = None
+ support.gc_collect()
+ self.assertIn(r, str(cm.warning.args[0]))
+
class ContextTests(unittest.TestCase):
@skip_if_broken_ubuntu_ssl
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -142,6 +142,8 @@
Library
-------
+- Issue #16900: Issue a ResourceWarning when an ssl socket is left unclosed.
+
- Issue #15545: Fix regression in sqlite3's iterdump method where it was
failing if the connection used a row factory (such as sqlite3.Row) that
produced unsortable objects. (Regression was introduced by fix for 9750).
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list