io.UnsupportedOperation when calling tell()
See original GitHub issueProblem 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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Strange, from a quick look at
TextIOWrapper
it should be calling the underlayingtell()
. I will add some additional tests and investigate.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…