Issue #10093: ResourceWarnings are now issued when files and sockets are
deallocated without explicit closing. These warnings are silenced by
default, except in pydebug mode.
diff --git a/Lib/socket.py b/Lib/socket.py
index 6af1964..2dc9736 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -108,7 +108,7 @@
if s.startswith("<socket object"):
s = "<%s.%s%s%s" % (self.__class__.__module__,
self.__class__.__name__,
- (self._closed and " [closed] ") or "",
+ getattr(self, '_closed', False) and " [closed] " or "",
s[7:])
return s