busio/UART: Correct and clarify readline() return.
Surely readline() "rtype" is string not int as stated (and not bytes as some might expect). Also it is not totally unambiguous what happens on a timeout so it would help to clarify in docs that on a timeout it does NOT return with what it has read so far, rather it leaves all that in the buffer ready for a future read and returns nothing. Likewise clarify that if timeout=0 but there is no newline it DOES return what it has read so far (NOT None). At least this is what I think it does and/or is supposed to do! Python docs are generally not too explicit about what is the proper treatment, so perhaps all the more reason to clarify the interpretation adopted?
This commit is contained in:
parent
2317fb5873
commit
f572b72306
|
@ -201,13 +201,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
|
|||
//| :rtype: int or None (on a non-blocking error)
|
||||
//|
|
||||
//| *New in CircuitPython 4.0:* No length parameter is permitted.
|
||||
|
||||
//|
|
||||
//| .. method:: readline()
|
||||
//|
|
||||
//| Read a line, ending in a newline character.
|
||||
//| Read a line, ending in a newline character, or
|
||||
//| return None if a timeout occurs sooner, or
|
||||
//| return everything readable if no newline is found and timeout=0
|
||||
//|
|
||||
//| :return: the line read
|
||||
//| :rtype: int or None
|
||||
//| :rtype: str or None
|
||||
//|
|
||||
//| .. method:: write(buf)
|
||||
//|
|
||||
|
|
Loading…
Reference in New Issue