Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

http.client.HTTPResponse is not playing nice (Python 3.x) #127

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

Closed
SimonSapin opened this issue Dec 17, 2013 · 2 comments
Closed

http.client.HTTPResponse is not playing nice (Python 3.x) #127

SimonSapin opened this issue Dec 17, 2013 · 2 comments

Comments

@SimonSapin
Copy link
Contributor

This gives the empty string on Python 3.x

from urllib.client import urlopen
html5lib.serialize(html5lib.parse(urlopen(
    'http://html5lib.readthedocs.org/en/latest/')))

The cause is a bug in Python: http://bugs.python.org/issue20007 , bug given CPython’s release cycle timeline I would like to have a work-around in html5lib.

The bug is triggered here:

isUnicode = isinstance(source.read(0), text_type)

Unfortunately, the only work-around I can think of (adding a special case if isinstance(source, http.client.HTTPResponse): isUnicode = False ) is very ugly.

@gsnedders
Copy link
Member

How important is this for WeasyPrint? Can push a new release if needs a timely turnaround.

@SimonSapin
Copy link
Contributor Author

A PyPI release would help, thanks. WeasyPrint recently switched to default to html5lib, and this bug breaks HTTP URLs (such as the command-line example given on the home page) on Python 3.x. It just silently renders an empty PDF.

SimonSapin added a commit to SimonSapin/html5lib-python that referenced this issue Dec 27, 2013
SimonSapin added a commit to SimonSapin/html5lib-python that referenced this issue Dec 27, 2013
SimonSapin added a commit to SimonSapin/html5lib-python that referenced this issue Dec 27, 2013
SimonSapin added a commit to SimonSapin/html5lib-python that referenced this issue Dec 27, 2013
SimonSapin added a commit to SimonSapin/html5lib-python that referenced this issue Dec 31, 2013
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Apr 26, 2015
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Apr 26, 2015
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Dec 12, 2015
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Dec 12, 2015
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Dec 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants