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

Function _decode_message

Lib/multiprocessing/resource_tracker.py:318–339  ·  view source on GitHub ↗
(line)

Source from the content-addressed store, hash-verified

316
317
318def _decode_message(line):
319 if line.startswith(b'{'):
320 try:
321 obj = json.loads(line.decode('ascii'))
322 except Exception as e:
323 raise ValueError("malformed resource_tracker message: %r" % (line,)) from e
324
325 cmd = obj["cmd"]
326 rtype = obj["rtype"]
327 b64 = obj.get("base64_name", "")
328
329 if not isinstance(cmd, str) or not isinstance(rtype, str) or not isinstance(b64, str):
330 raise ValueError("malformed resource_tracker fields: %r" % (obj,))
331
332 try:
333 name = base64.urlsafe_b64decode(b64).decode('utf-8', 'surrogateescape')
334 except ValueError as e:
335 raise ValueError("malformed resource_tracker base64_name: %r" % (b64,)) from e
336 else:
337 cmd, rest = line.strip().decode('ascii').split(':', maxsplit=1)
338 name, rtype = rest.rsplit(':', maxsplit=1)
339 return cmd, rtype, name
340
341
342def main(fd):

Callers 1

mainFunction · 0.85

Calls 7

startswithMethod · 0.45
loadsMethod · 0.45
decodeMethod · 0.45
getMethod · 0.45
splitMethod · 0.45
stripMethod · 0.45
rsplitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…