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

Make sure we're working with UTF8 string #1028

Merged
merged 1 commit into from
Mar 9, 2016

Conversation

br0ziliy
Copy link
Contributor

Depending on the URL, response.iter_content() in Python 2/3 will return either:

  • type 'unicode'/class 'str' (for "plain" HTML)
  • type 'str'/class 'bytes' (for binary streams, like file URLs)

To distinguish between the two situations we're checking if we got string or
bytes, and proceed accordingly.

This also fixes #1021

Depending on the URL, response.iter_content() in Python 2/3 will return either:
- `type 'unicode'`/`class 'str'` (for "plain" HTML)
- `type 'str'`/`class 'bytes'` (for binary streams, like file URLs)

To distinguish between the two situations we're checking if we got string or
bytes, and proceed accordingly.

This also fixes sopel-irc#1021
@elad661 elad661 merged commit a32ce8e into sopel-irc:master Mar 9, 2016
@elad661
Copy link
Contributor

elad661 commented Mar 9, 2016

Merged, thanks.

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.

url: UnicodeEncodeError
2 participants