tensorflow / tensorflow/tensorflow

Cannot seek on write only tf.gfile.GFile

Open
#32,122 13 comments 0 reactions 1 assignee View on GitHub

@Venkat6871 is already working on this.

Since May 19, 2026.

comp:apis stat:contribution welcome TF 2.11 type:bug
Dominant language
C++
Stars
200k
Forks
76.9k
Avg merge
2d 3h
Merged PRs (30d)
433

Description

System information

  • Have I written custom code: Yes
  • OS Platform and Distribution: Linux Ubuntu 18.04
  • TensorFlow installed from: binary
  • TensorFlow version: v1.14.0-rc1-22-gaf24dc9 1.14.0
  • Python version: 3.6

Describe the current behavior
Calling seek() on a tf.gfile.GFile opened in write only mode raises tensorflow.python.framework.errors_impl.PermissionDeniedError.

Describe the expected behavior
GFile should support the Python IO semantics that supports seeking on a write only file.

More generally it would be preferable if GFile followed the API of Python's io.IOBase.

Code to reproduce the issue

import tensorflow as tf

with tf.io.gfile.GFile('test.txt', 'w') as f:
    f.seek(0)

Other info / logs

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/VENV/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/VENV/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 146, in seek
    self._preread_check()
  File "/VENV/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 82, in _preread_check
    "File isn't open for reading")
tensorflow.python.framework.errors_impl.PermissionDeniedError: File isn't open for reading

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.