<p dir="auto">When I use tf.gfile.GFile and set mode='rb' to open a file on windows, it will read as 'str' instead of 'byte'. For example,</p>
<p dir="auto">f = tf.gfile.GFile("d2f42068.ini", mode='rb')<br>
f.readline()<br>
The result shows<br>
'\n'.<br>
It should be<br>
b'\n'</p>
<p dir="auto">I find the gfile.py replace the 'r' to empty.<br>
def <strong>init</strong>(self, name, mode='r'):<br>
mode = mode.replace('b', '')<br>
super(FastGFile, self).<strong>init</strong>(name=name, mode=mode)</p>
<p dir="auto">This issue will cause some error of data reading on windows.</p>
<p dir="auto">My OS is win10 x64. The version of tensorflow is r0.12.</p>
<p dir="auto">NOTE: Only file GitHub issues for bugs and feature requests.  All other topics will be closed.</p>
<p dir="auto">For general support from the community, see <a href="https://stackoverflow.com/questions/tagged/tensorflow" rel="nofollow">StackOverflow</a>.<br>
To make bugs and feature requests more easy to find and organize, we close issues that are deemed<br>
out of scope for GitHub Issues and point people to StackOverflow.</p>
<p dir="auto">For bugs or installation issues, please provide the following information.<br>
The more information you provide, the more easily we will be able to offer<br>
help and advice.</p>
<h3 dir="auto">What related GitHub issues or StackOverflow threads have you found by searching the web for your problem?</h3>
<p dir="auto">None</p>
<h3 dir="auto">Environment info</h3>
<p dir="auto">Operating System: macOS Sierra 10.12.2</p>
<p dir="auto">Installed version of CUDA and cuDNN: None<br>
(please attach the output of <code class="notranslate">ls -l /path/to/cuda/lib/libcud*</code>): None</p>
<p dir="auto">If installed from binary pip package, provide:</p>
<ol dir="auto">
<li>A link to the pip package you installed:</li>
<li>The output from <code class="notranslate">python -c "import tensorflow; print(tensorflow.__version__)"</code>.</li>
</ol>
<p dir="auto">If installed from source, provide</p>
<ol dir="auto">
<li>
<p dir="auto">The commit hash (<code class="notranslate">git rev-parse HEAD</code>)<br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/tensorflow/tensorflow/commit/4d924e796368163eff11a8151e8505715345f58d/hovercard" href="https://github.com/tensorflow/tensorflow/commit/4d924e796368163eff11a8151e8505715345f58d"><tt>4d924e7</tt></a></p>
</li>
<li>
<p dir="auto">The output of <code class="notranslate">bazel version</code><br>
0.4.3-homebrew</p>
</li>
</ol>
<h3 dir="auto">If possible, provide a minimal reproducible example (We usually don't have time to read hundreds of lines of your code)</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf
import pickle

f = tf.gfile.GFile(&quot;data_batch_1&quot;)
pickle.load(f, encoding='latin1')"><pre class="notranslate"><code class="notranslate">import tensorflow as tf
import pickle

f = tf.gfile.GFile("data_batch_1")
pickle.load(f, encoding='latin1')
</code></pre></div>
<h3 dir="auto">What other attempted solutions have you tried?</h3>
<p dir="auto">I tried to manually read all data into a variable: <code class="notranslate">s = f.read()</code> and unpickle it: <code class="notranslate">pickle.loads(s, encoding='latin')</code>. It works well.</p>
<h3 dir="auto">Logs or other output that would be helpful</h3>
<p dir="auto">(If logs are large, please upload as attachment or provide link).</p>
<p dir="auto"><code class="notranslate">TypeError: a bytes-like object is required, not 'str'</code></p>
<p dir="auto">I don't know why this happened. I checked the file_io code, and it returns byte object when calling <code class="notranslate">read</code>. So maybe this is something about pickle, any ideas?</p>