question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

io.UnsupportedOperation when calling tell()

See original GitHub issue

Problem description

Performing a file_obj.tell() on a file object returned by smart_open.open results in an error in the 4.1.2 release. However, when I switch to the previous 4.1.0 release, this does not occur. A quick search seems to point to #578 which introduces use of io.TextIOWrapper. Calling tell() is not using the underlying tell() from the cloud specific writers. The original codecs implementation inherits functions like tell() from the file object that is passed in.

Steps/code to reproduce the problem

cloud_location = 's3://examplebucket/foobar'
import smart_open
with smart_open.open(cloud_location, 'w') as f:
    print(f.tell())

Above code with a valid cloud_location throws the following:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
io.UnsupportedOperation: underlying stream is not seekable

Versions

Linux-5.4.0-1029-aws-x86_64-with-glibc2.29 Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] smart_open 4.1.2

Checklist

Before you create the issue, please make sure you have:

  • Described the problem clearly
  • Provided a minimal reproducible example, including any required data
  • Provided the version numbers of the relevant software

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
markopycommented, Feb 9, 2021

Strange, from a quick look at TextIOWrapper it should be calling the underlaying tell(). I will add some additional tests and investigate.

0reactions
quantumfusioncommented, Feb 9, 2021

I see. Thanks for the clarification. Sounds like we need to go through and clean up our usage of tell(). Luckily it seems to only be used for a bunch of logging…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python error message io.UnsupportedOperation: not readable
You are opening the file as "w" , which stands for writable. Using "w" you won't be able to read the file. Use...
Read more >
io.UnsupportedOperation: seek · Issue #107 - GitHub
Hi all, I am new to parallel python programming and I am trying to run one function in parallel. Previously I tried with...
Read more >
16.2. io — Core tools for working with streams - Read the Docs
Binary I/O (also called buffered I/O) expects bytes-like objects and produces bytes ... If False , seek() , tell() and truncate() will raise...
Read more >
io.UnsupportedOperation: not readable - Python Forum
#difference about this program is that it calls the writeMovies function ... print ( "Bye!" ) if __name__ = = "__main__" : main()...
Read more >
Python File Seek(): Move File Pointer Position - PYnative
The seek() function sets the position of a file pointer and the tell() function ... File handle is also called as file pointer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found