MCPcopy Index your code
hub / github.com/RustPython/RustPython / __repr__

Method __repr__

Lib/socket.py:247–275  ·  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

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected