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

Method readline

Lib/asyncio/streams.py:543–572  ·  view source on GitHub ↗

Read chunk of data from the stream until newline (b'\n') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes

(self)

Source from the content-addressed store, hash-verified

541 self._waiter = None
542
543 async def readline(self):
544 """Read chunk of data from the stream until newline (b'\n') is found.
545
546 On success, return chunk that ends with newline. If only partial
547 line can be read due to EOF, return incomplete line without
548 terminating newline. When EOF was reached while no bytes read, empty
549 bytes object is returned.
550
551 If limit is reached, ValueError will be raised. In that case, if
552 newline was found, complete line including newline will be removed
553 from internal buffer. Else, internal buffer will be cleared. Limit is
554 compared against part of the line without newline.
555
556 If stream was paused, this function will automatically resume it if
557 needed.
558 """
559 sep = b'\n'
560 seplen = len(sep)
561 try:
562 line = await self.readuntil(sep)
563 except exceptions.IncompleteReadError as e:
564 return e.partial
565 except exceptions.LimitOverrunError as e:
566 if self._buffer.startswith(sep, e.consumed):
567 del self._buffer[:e.consumed + seplen]
568 else:
569 self._buffer.clear()
570 self._maybe_resume_transport()
571 raise ValueError(e.args[0])
572 return line
573
574 async def readuntil(self, separator=b'\n'):
575 """Read data from the stream until ``separator`` is found.

Callers 12

__anext__Method · 0.95
test_readlineMethod · 0.95
test_at_eofMethod · 0.95
test_readline_limitMethod · 0.95
test_readline_eofMethod · 0.95
test_exception_waiterMethod · 0.95
test_exception_cancelMethod · 0.95

Calls 5

readuntilMethod · 0.95
lenFunction · 0.85
startswithMethod · 0.45
clearMethod · 0.45

Tested by 11

test_readlineMethod · 0.76
test_at_eofMethod · 0.76
test_readline_limitMethod · 0.76
test_readline_eofMethod · 0.76
test_exception_waiterMethod · 0.76
test_exception_cancelMethod · 0.76