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

Function _iterencode

Lib/json/encoder.py:426–460  ·  view source on GitHub ↗
(o, _current_indent_level)

Source from the content-addressed store, hash-verified

424 del markers[markerid]
425
426 def _iterencode(o, _current_indent_level):
427 if isinstance(o, str):
428 yield _encoder(o)
429 elif o is None:
430 yield 'null'
431 elif o is True:
432 yield 'true'
433 elif o is False:
434 yield 'false'
435 elif isinstance(o, int):
436 # see comment for int/float in _make_iterencode
437 yield _intstr(o)
438 elif isinstance(o, float):
439 # see comment for int/float in _make_iterencode
440 yield _floatstr(o)
441 elif isinstance(o, (list, tuple)):
442 yield from _iterencode_list(o, _current_indent_level)
443 elif isinstance(o, dict):
444 yield from _iterencode_dict(o, _current_indent_level)
445 else:
446 if markers is not None:
447 markerid = id(o)
448 if markerid in markers:
449 raise ValueError("Circular reference detected")
450 markers[markerid] = o
451 newobj = _default(o)
452 try:
453 yield from _iterencode(newobj, _current_indent_level)
454 except GeneratorExit:
455 raise
456 except BaseException as exc:
457 exc.add_note(f'when serializing {type(o).__name__} object')
458 raise
459 if markers is not None:
460 del markers[markerid]
461 return _iterencode

Callers 3

iterencodeMethod · 0.85
_iterencode_listFunction · 0.85
_iterencode_dictFunction · 0.85

Calls 5

isinstanceFunction · 0.85
_iterencode_listFunction · 0.85
_iterencode_dictFunction · 0.85
idFunction · 0.85
add_noteMethod · 0.80

Tested by

no test coverage detected