Skip to content

Commit f572b72

Browse files
authored
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?
1 parent 2317fb5 commit f572b72

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

shared-bindings/busio/UART.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
201201
//| :rtype: int or None (on a non-blocking error)
202202
//|
203203
//| *New in CircuitPython 4.0:* No length parameter is permitted.
204-
204+
//|
205205
//| .. method:: readline()
206206
//|
207-
//| Read a line, ending in a newline character.
207+
//| Read a line, ending in a newline character, or
208+
//| return None if a timeout occurs sooner, or
209+
//| return everything readable if no newline is found and timeout=0
208210
//|
209211
//| :return: the line read
210-
//| :rtype: int or None
212+
//| :rtype: str or None
211213
//|
212214
//| .. method:: write(buf)
213215
//|

0 commit comments

Comments
 (0)