You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Versions of smart_open before 6.0.0 successfully open file identifiers passed from the zipfile module.
However, starting from 6.0.0 the same code yields TypeError: don't know how to handle uri <zipfile.ZipExtFile name='FILENAME' mode='r' compress_type=deflate>
(where FILENAME is the actual name of the file inside the archive)
Looks like a regression to me. Is it somehow related to this PR?
Anyway, this is really inconvenient. Is there now any other way of reading files from ZIP archives directly, without decompressing on disk?
Many thanks for clarifying this.
Steps/code to reproduce the problem
Minimal reproducible example:
import zipfile
from smart_open import open
zf = zipfile.ZipFile("ANY_ZIP_FILE")
file2read = zf.open("FILENAME_INSIDE_ARCHIVE")
data = open(file2read, 'r')
This code works flawlessly on smart_open 5.2.1 but fails on smart_open 6.0.0 with:
Traceback (most recent call last):
File "test_sm.py", line 13, in <module>
data = open(file2read, 'r')
File ".../lib/python3.9/site-packages/smart_open/smart_open_lib.py", line 224, in open
binary = _open_binary_stream(uri, binary_mode, transport_params)
File ".../lib/python3.9/site-packages/smart_open/smart_open_lib.py", line 396, in _open_binary_stream
raise TypeError("don't know how to handle uri %s" % repr(uri))
TypeError: don't know how to handle uri <zipfile.ZipExtFile name='FILENAME_INSIDE_ARCHIVE' mode='r' compress_type=deflate>
Versions
I observe this on at least two independent machines with different Python version:
We dropped support for your specific use case because it is inconsistent with the built-in open function, which only handles string input for the first parameter.
Yes, you've correctly pointed to the PR that dropped the support.
You can still achieve what you want by following the instructions here.
Problem description
Hi,
Versions of
smart_open
before 6.0.0 successfully open file identifiers passed from the zipfile module.However, starting from 6.0.0 the same code yields
TypeError: don't know how to handle uri <zipfile.ZipExtFile name='FILENAME' mode='r' compress_type=deflate>
(where FILENAME is the actual name of the file inside the archive)
Looks like a regression to me. Is it somehow related to this PR?
Anyway, this is really inconvenient. Is there now any other way of reading files from ZIP archives directly, without decompressing on disk?
Many thanks for clarifying this.
Steps/code to reproduce the problem
Minimal reproducible example:
This code works flawlessly on
smart_open 5.2.1
but fails onsmart_open 6.0.0
with:Versions
I observe this on at least two independent machines with different Python version:
The text was updated successfully, but these errors were encountered: