[Python-checkins] cpython: fix isuse #13248: remove previously deprecated asyncore.dispatcher __getattr__

giampaolo.rodola python-checkins at python.org
Tue Apr 29 02:04:24 CEST 2014


http://hg.python.org/cpython/rev/2cceb8cb552b
changeset:   90495:2cceb8cb552b
parent:      90493:d1a03834cec7
user:        Giampaolo Rodola' <g.rodola at gmail.com>
date:        Tue Apr 29 02:03:40 2014 +0200
summary:
  fix isuse #13248: remove previously deprecated asyncore.dispatcher __getattr__ cheap inheritance hack.

files:
  Lib/asyncore.py           |  14 --------------
  Lib/test/test_asyncore.py |  17 -----------------
  Misc/NEWS                 |   3 +++
  3 files changed, 3 insertions(+), 31 deletions(-)


diff --git a/Lib/asyncore.py b/Lib/asyncore.py
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -404,20 +404,6 @@
                 if why.args[0] not in (ENOTCONN, EBADF):
                     raise
 
-    # cheap inheritance, used to pass all other attribute
-    # references to the underlying socket object.
-    def __getattr__(self, attr):
-        try:
-            retattr = getattr(self.socket, attr)
-        except AttributeError:
-            raise AttributeError("%s instance has no attribute '%s'"
-                                 %(self.__class__.__name__, attr))
-        else:
-            msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s " \
-                  "instead" % {'me' : self.__class__.__name__, 'attr' : attr}
-            warnings.warn(msg, DeprecationWarning, stacklevel=2)
-            return retattr
-
     # log and log_info may be overridden to provide more sophisticated
     # logging and warning methods. In general, log is for 'hit' logging
     # and 'log_info' is for informational, warning and error logging.
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -316,23 +316,6 @@
                     'warning: unhandled connect event']
         self.assertEqual(lines, expected)
 
-    def test_issue_8594(self):
-        # XXX - this test is supposed to be removed in next major Python
-        # version
-        d = asyncore.dispatcher(socket.socket())
-        # make sure the error message no longer refers to the socket
-        # object but the dispatcher instance instead
-        self.assertRaisesRegex(AttributeError, 'dispatcher instance',
-                               getattr, d, 'foo')
-        # cheap inheritance with the underlying socket is supposed
-        # to still work but a DeprecationWarning is expected
-        with warnings.catch_warnings(record=True) as w:
-            warnings.simplefilter("always")
-            family = d.family
-            self.assertEqual(family, socket.AF_INET)
-            self.assertEqual(len(w), 1)
-            self.assertTrue(issubclass(w[0].category, DeprecationWarning))
-
     def test_strerror(self):
         # refers to bug #8573
         err = asyncore._strerror(errno.EPERM)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,9 @@
 Library
 -------
 
+- Issue #13248: removed previously deprecated asyncore.dispatcher __getattr__
+  cheap inheritance hack.
+
 - Issue #9815: assertRaises now tries to clear references to local variables
   in the exception's traceback.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list