From 112ea6bfa61e67516f8ab7c0b5b46911d5f7e060 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 18 Aug 2001 21:00:39 +0000 Subject: [PATCH] Inspired by Greg Stein's proposed simplification of the _closesocket class, I came up with an even simpler solution: raise the error in __getattr__(). --- Lib/socket.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/socket.py b/Lib/socket.py index ce72b65c6e4..ec8d61092b9 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -155,13 +155,9 @@ class _socketobject: class _closedsocket: - def _bummer(self): + def __getattr__(self, name): raise error(9, 'Bad file descriptor') - _s = "def %s(self, *args): self._bummer()\n\n" - for _m in _socketmethods: - exec _s % _m - class _fileobject: