Open
Conversation
sbinet
reviewed
Feb 20, 2026
Member
sbinet
left a comment
There was a problem hiding this comment.
thanks for the PR.
I have a couple of comments, see below.
also, it'd be great to add tests for this.
thanks again.
sbinet
reviewed
Feb 23, 2026
| return o.readResult(b) | ||
| } | ||
|
|
||
| func (o *File) Readline() (Object, error) { |
Member
There was a problem hiding this comment.
perhaps add a test for this new method in tests/file.py ?
| }, 0, "flush() -> Flush the write buffers of the stream if applicable. This does nothing for read-only and non-blocking streams.") | ||
| FileType.Dict["readline"] = MustNewMethod("readline", func(self Object) (Object, error) { | ||
| return self.(*File).Readline() | ||
| }, 0, "readline() -> next line from the file, as a string.\n\nRetains newline. A non-empty string returned implies that readline() returned\na line, empty string returned implies that EOF is reached.") |
Member
There was a problem hiding this comment.
the actual documentation from CPython reads:
readline(size=-1, /)
Read and return one line from the stream. If size is specified, at most size bytes will be read.
The line terminator is always b'\n' for binary files; for text files, the newline argument to open can be used to select the line terminator(s) recognized.
https://docs.python.org/3/library/io.html#io.IOBase.readline
well, newline isn't implemented (yet) on stdlib.open but...
(perhaps we could also fix the readline signature to match the CPython one, w/o actually implementing the size thing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since liner takes over control of stdin in the REPL, an InputHook is added and registered in REPL mode, which will use liner to get the input instead of reading from stdin directly.