MCPcopy Index your code
hub / github.com/python/cpython / __repr__

Method __repr__

Lib/socket.py:248–276  ·  view source on GitHub ↗

Wrap __repr__() to reveal the real class name and socket address(es).

(self)

Source from the content-addressed store, hash-verified

246 self.close()
247
248 def __repr__(self):
249 """Wrap __repr__() to reveal the real class name and socket
250 address(es).
251 """
252 closed = getattr(self, '_closed', False)
253 s = "<%s.%s%s fd=%i, family=%s, type=%s, proto=%i" \
254 % (self.__class__.__module__,
255 self.__class__.__qualname__,
256 " [closed]" if closed else "",
257 self.fileno(),
258 self.family,
259 self.type,
260 self.proto)
261 if not closed:
262 # getsockname and getpeername may not be available on WASI.
263 try:
264 laddr = self.getsockname()
265 if laddr:
266 s += ", laddr=%s" % str(laddr)
267 except (error, AttributeError):
268 pass
269 try:
270 raddr = self.getpeername()
271 if raddr:
272 s += ", raddr=%s" % str(raddr)
273 except (error, AttributeError):
274 pass
275 s += '>'
276 return s
277
278 def __getstate__(self):
279 raise TypeError(f"cannot pickle {self.__class__.__name__!r} object")

Callers

nothing calls this directly

Calls 4

strFunction · 0.85
filenoMethod · 0.45
getsocknameMethod · 0.45
getpeernameMethod · 0.45

Tested by

no test coverage detected