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

sendDocument does file_content.encode()? #49

Closed
cosine0 opened this issue Aug 31, 2015 · 3 comments
Closed

sendDocument does file_content.encode()? #49

cosine0 opened this issue Aug 31, 2015 · 3 comments

Comments

@cosine0
Copy link

cosine0 commented Aug 31, 2015

When I call sendDocument() with file which is already binary (mode="rb"), it tries to encode it once more. So if the file content is containing non-ascii byte, it faild with:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

This is caused by here.
in inputfile.py line 90:

    def _parse(self, form):
        if sys.version_info > (3,):
            # on Python 3 form needs to be byte encoded
            encoded_form = []
            for item in form:
                try:
                    encoded_form.append(item.encode())
                except AttributeError:
                    encoded_form.append(item)

            return b'\r\n'.join(encoded_form)
        return '\r\n'.join(form)
@leandrotoledo
Copy link
Member

Uhm, would you mind to share this document so I can reproduce locallly? You can reach out me on telegram by @leandrotoledo.

Thanks for reporting this.

@cosine0
Copy link
Author

cosine0 commented Sep 1, 2015

Oh, sorry that was because filename was in unicode. I forgot to encode filename.
It works well when filename is encoded.

@cosine0 cosine0 closed this as completed Sep 2, 2015
@leandrotoledo
Copy link
Member

Found the issue?
Em 02/09/2015 9:02 AM, "cosine0" notifications@github.com escreveu:

Closed #49
#49.


Reply to this email directly or view it on GitHub
#49 (comment)
.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants