Clarify docstring: At EOF, GFile.readline() returns "".

Along the way, fix a comment about the same topic.

PiperOrigin-RevId: 311537677
Change-Id: I8dbd4fbf12f617efc5fdff0eb615337dc9c2fa8d
This commit is contained in:
A. Unique TensorFlower 2020-05-14 08:35:00 -07:00 committed by TensorFlower Gardener
parent e2f8f5ad62
commit ed01ecd92d
2 changed files with 2 additions and 2 deletions

View File

@ -144,7 +144,7 @@ def get_vocabulary_from_file(vocabulary_path, encoding="utf-8"):
vocab = [] vocab = []
with gfile.GFile(vocabulary_path, "r") as reader: with gfile.GFile(vocabulary_path, "r") as reader:
while True: while True:
# Get the next line, and break if it is None. # Get the next line (incl. \n), and break if nothing is left to read.
text = reader.readline() text = reader.readline()
if not text: if not text:
break break

View File

@ -165,7 +165,7 @@ class FileIO(object):
self._read_buf.seek(offset) self._read_buf.seek(offset)
def readline(self): def readline(self):
r"""Reads the next line from the file. Leaves the '\n' at the end.""" r"""Reads the next line, keeping \n. At EOF, returns ''."""
self._preread_check() self._preread_check()
return self._prepare_value(self._read_buf.readline()) return self._prepare_value(self._read_buf.readline())