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

TextIOWrapper fails with SystemError when reading HTTPResponse #49878

Closed
jhylton mannequin opened this issue Mar 31, 2009 · 10 comments
Closed

TextIOWrapper fails with SystemError when reading HTTPResponse #49878

jhylton mannequin opened this issue Mar 31, 2009 · 10 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jhylton
Copy link
Mannequin

jhylton mannequin commented Mar 31, 2009

BPO 5628
Nosy @orsenthil, @pitrou, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-05-14.21:15:12.304>
created_at = <Date 2009-03-31.17:08:43.740>
labels = ['type-bug', 'library']
title = 'TextIOWrapper fails with SystemError when reading HTTPResponse'
updated_at = <Date 2009-05-14.21:15:12.303>
user = 'https://bugs.python.org/jhylton'

bugs.python.org fields:

activity = <Date 2009-05-14.21:15:12.303>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2009-05-14.21:15:12.304>
closer = 'benjamin.peterson'
components = ['Library (Lib)']
creation = <Date 2009-03-31.17:08:43.740>
creator = 'jhylton'
dependencies = []
files = []
hgrepos = []
issue_num = 5628
keywords = []
message_count = 10.0
messages = ['84840', '84945', '84951', '84953', '84961', '84963', '84968', '84970', '87764', '87765']
nosy_count = 4.0
nosy_names = ['jhylton', 'orsenthil', 'pitrou', 'benjamin.peterson']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue5628'
versions = ['Python 3.0', 'Python 3.1']

@jhylton
Copy link
Mannequin Author

jhylton mannequin commented Mar 31, 2009

import io
import urllib.request

f_bytes = urllib.request.urlopen("http://www.python.org/")
f_string = io.TextIOWrapper(f_bytes, "iso-8859-1")
print(f_string.read())

@jhylton jhylton mannequin added the stdlib Python modules in the Lib dir label Mar 31, 2009
@benjaminp
Copy link
Contributor

Fixed in r70928.

@orsenthil
Copy link
Member

Nope, this is not yet fixed.

$ ./python 
Python 3.1a1+ (py3k:70929, Mar 31 2009, 19:18:12) 
[GCC 4.3.2] on linux2
...
...
>>> f_bytes = urllib.request.urlopen("http://www.python.org")
>>> f_string = io.TextIOWrapper(f_bytes,"iso-8859-1")
>>> print(f_string.read())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: not readable

@orsenthil orsenthil reopened this Apr 1, 2009
@pitrou
Copy link
Member

pitrou commented Apr 1, 2009

urllib.response.addinfourl doesn't seem to implement the required ABC
(BufferedIOBase) properly. It misses the read1() method. Also, it claims
not to be readable:

>>> f_bytes = urllib.request.urlopen("http://www.python.org/")
>>> f_bytes.readable()
False

@pitrou pitrou added the type-bug An unexpected behavior, bug, or error label Apr 1, 2009
@jhylton
Copy link
Mannequin Author

jhylton mannequin commented Apr 1, 2009

I just wanted to mention that the current head of py3k returns an
http.client.HTTPResponse and not a urllib.respone.addinfourl. That
doesn't mean it is the right thing to pass to TextIOWrapper. It's an
instance of RawIOBase.

@orsenthil
Copy link
Member

Jeremy Hylton wrote:

 That doesn't mean it is the right thing to pass to TextIOWrapper.  It's an
instance of RawIOBase.

I guess, you meant " That doesn't mean it is *not* the right thing to
pass to TextIOWrapper".

@orsenthil
Copy link
Member

With the changes r70935, this works.

@benjaminp
Copy link
Contributor

Please note that passing a instance of RawIOBase (as HTTPResponse) is
to TextIOWrapper is *not* supported. You must first wrap the raw IO in
a BufferIOBase instance.

@pitrou
Copy link
Member

pitrou commented May 14, 2009

I suppose it is fixed, isn't it?

@benjaminp
Copy link
Contributor

Yes

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants