diff options
| author | AndrewR-L <59139513+AndrewR-L@users.noreply.github.com> | 2020-04-17 15:10:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-17 15:10:36 +0100 |
| commit | f572b723060382bbc9ca7a3edc88cb7c30fdcc30 (patch) | |
| tree | 8cd2e66a2fc3d6a4d6e3945d9492dfef60488472 | |
| parent | 2317fb58732c2e1ae0d2a6c38d6df6e96a3cf7b4 (diff) | |
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?
| -rw-r--r-- | shared-bindings/busio/UART.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 02c5afb16..e4a6b93d9 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -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) //| |
