Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8af740c

Browse files
committed
fix isuse #13248: remove previously deprecated asyncore.dispatcher __getattr__ cheap inheritance hack.
1 parent 63aeb71 commit 8af740c

3 files changed

Lines changed: 3 additions & 31 deletions

File tree

Lib/asyncore.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -404,20 +404,6 @@ def close(self):
404404
if why.args[0] not in (ENOTCONN, EBADF):
405405
raise
406406

407-
# cheap inheritance, used to pass all other attribute
408-
# references to the underlying socket object.
409-
def __getattr__(self, attr):
410-
try:
411-
retattr = getattr(self.socket, attr)
412-
except AttributeError:
413-
raise AttributeError("%s instance has no attribute '%s'"
414-
%(self.__class__.__name__, attr))
415-
else:
416-
msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s " \
417-
"instead" % {'me' : self.__class__.__name__, 'attr' : attr}
418-
warnings.warn(msg, DeprecationWarning, stacklevel=2)
419-
return retattr
420-
421407
# log and log_info may be overridden to provide more sophisticated
422408
# logging and warning methods. In general, log is for 'hit' logging
423409
# and 'log_info' is for informational, warning and error logging.

Lib/test/test_asyncore.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -316,23 +316,6 @@ def test_unhandled(self):
316316
'warning: unhandled connect event']
317317
self.assertEqual(lines, expected)
318318

319-
def test_issue_8594(self):
320-
# XXX - this test is supposed to be removed in next major Python
321-
# version
322-
d = asyncore.dispatcher(socket.socket())
323-
# make sure the error message no longer refers to the socket
324-
# object but the dispatcher instance instead
325-
self.assertRaisesRegex(AttributeError, 'dispatcher instance',
326-
getattr, d, 'foo')
327-
# cheap inheritance with the underlying socket is supposed
328-
# to still work but a DeprecationWarning is expected
329-
with warnings.catch_warnings(record=True) as w:
330-
warnings.simplefilter("always")
331-
family = d.family
332-
self.assertEqual(family, socket.AF_INET)
333-
self.assertEqual(len(w), 1)
334-
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
335-
336319
def test_strerror(self):
337320
# refers to bug #8573
338321
err = asyncore._strerror(errno.EPERM)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Core and Builtins
6060
Library
6161
-------
6262

63+
- Issue #13248: removed previously deprecated asyncore.dispatcher __getattr__
64+
cheap inheritance hack.
65+
6366
- Issue #9815: assertRaises now tries to clear references to local variables
6467
in the exception's traceback.
6568

0 commit comments

Comments
 (0)