Bring back filename parameter to compression_wrapper #497
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Smart_open 1.8.4 used to have a nifty
_compression_wrapper
function. It was internal (_
prefix) but generally useful.That function doesn't exist any more in smart_open 2.0.0. It was promoted to a public
compression.compression_wrapper
which is almost identical, but not quite. The new function doesn't accept a filename, and is instead hard-wired to extract the filename fromfile_obj.name
.This is undesirable in our system, where hacking
file_obj
to add the.name
attribute is complicated (and unnecessary).This PR brings back the option of supplying own filename. It's fully backward compatible: with no
filename
specified, it will fall back tofile_obj.name
like before.Checklist
Before you create the PR, please make sure you have: