Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance add_file_from_memory #85

Merged
merged 7 commits into from Oct 20, 2019

Conversation

MartinFalatic
Copy link
Contributor

Closes #68, #69

@MartinFalatic
Copy link
Contributor Author

Depending on which or #85 or #86 is merged first, the other will need to be rebased before merge.

@Changaco
Copy link
Owner

This branch doesn't really fix #68 and #69, it only clarifies the docstring of the add_file_from_memory method a little.

@MartinFalatic
Copy link
Contributor Author

Those issues are both a failure of information and example. As the only examples provided are in the form of tests and the minimalist docstrings, I enhanced both to better specify exactly what the parameters must be in order for the process to succeed.

The test, in particular, was designed to show the best practice for various inputs is to encode them as binary if they aren't already.

I originally had a test that included a non-binary string, thus the "unnecessary code" you removed. In fact, that was to be yet another example of how to correctly handle non-binary string inputs, but it seems better served by the commentary within the test stating that non-binary inputs will cause unwelcome results.

Correct documentation would have prevented both issues, so yes, this fixes that gap. The only thing that would work better is explicitly disallowing any non-binary input, but that might break some applications of it (applications that would break the moment they use Python 3 and default unicode strings - that's how I first learned that, other than unaddressed bug reports, this was undocumented).

@Changaco
Copy link
Owner

It's not just a documentation issue. We can make the add_file_from_memory method more friendly by modifying it to accept a single bytestring as well as a list of bytestrings, as proposed in #68 (comment).

I don't want to close #69 until I see a non-failing test proving that NUL characters are in fact handled correctly.

@Changaco Changaco merged commit 4375f15 into Changaco:master Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add_file_from_memory() can't add binary files
3 participants