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

Function read_decimalnl_short

Lib/pickletools.py:750–770  ·  view source on GitHub ↗

r""" >>> import io >>> read_decimalnl_short(io.BytesIO(b"1234\n56")) 1234 >>> read_decimalnl_short(io.BytesIO(b"1234L\n56")) Traceback (most recent call last): ... ValueError: invalid literal for int() with base 10: b'1234L'

(f)

Source from the content-addressed store, hash-verified

748
749
750def read_decimalnl_short(f):
751 r"""
752 >>> import io
753 >>> read_decimalnl_short(io.BytesIO(b"1234\n56"))
754 1234
755
756 >>> read_decimalnl_short(io.BytesIO(b"1234L\n56"))
757 Traceback (most recent call last):
758 ...
759 ValueError: invalid literal for int() with base 10: b'1234L'
760 """
761
762 s = read_stringnl(f, decode=False, stripquotes=False)
763
764 # There's a hack for True and False here.
765 if s == b"00":
766 return False
767 elif s == b"01":
768 return True
769
770 return int(s)
771
772def read_decimalnl_long(f):
773 r"""

Callers

nothing calls this directly

Calls 1

read_stringnlFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…