From ed01ecd92d4376d519247f1d3ce2d8ab5c1d99da Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Thu, 14 May 2020 08:35:00 -0700 Subject: [PATCH] Clarify docstring: At EOF, GFile.readline() returns "". Along the way, fix a comment about the same topic. PiperOrigin-RevId: 311537677 Change-Id: I8dbd4fbf12f617efc5fdff0eb615337dc9c2fa8d --- tensorflow/python/keras/layers/preprocessing/table_utils.py | 2 +- tensorflow/python/lib/io/file_io.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/keras/layers/preprocessing/table_utils.py b/tensorflow/python/keras/layers/preprocessing/table_utils.py index 88e9d95e2ed..f5397da1f3e 100644 --- a/tensorflow/python/keras/layers/preprocessing/table_utils.py +++ b/tensorflow/python/keras/layers/preprocessing/table_utils.py @@ -144,7 +144,7 @@ def get_vocabulary_from_file(vocabulary_path, encoding="utf-8"): vocab = [] with gfile.GFile(vocabulary_path, "r") as reader: 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() if not text: break diff --git a/tensorflow/python/lib/io/file_io.py b/tensorflow/python/lib/io/file_io.py index a1db2fb056c..7c484c825d3 100644 --- a/tensorflow/python/lib/io/file_io.py +++ b/tensorflow/python/lib/io/file_io.py @@ -165,7 +165,7 @@ class FileIO(object): self._read_buf.seek(offset) 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() return self._prepare_value(self._read_buf.readline())