This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: HTTPResponse is missing an implementation of readinto
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jon.Kuhn, fbidu, orsenthil, pitrou, python-dev, r.david.murray
Priority: normal Keywords: easy, patch

Created on 2011-11-23 18:13 by r.david.murray, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
issue13464.patch Jon.Kuhn, 2011-12-04 04:36 Patch based on 06087f6890af review
issue13464_r1.patch Jon.Kuhn, 2011-12-04 16:54 Updated Patch review
Pull Requests
URL Status Linked Edit
PR 22737 fbidu, 2020-10-23 19:09
Messages (7)
msg148199 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-11-23 18:13
HTTPResponse subclasses RawIOBase, but does not provide an implementation of readinto, only read.  This means that it is not conforming to the IO spec, and so it cannot be wrapped in a BufferedIOBase when using the C version of io.
msg148837 - (view) Author: Jon Kuhn (Jon.Kuhn) * Date: 2011-12-04 04:36
This is my first contribution to a real open source project.

Attached is my patch.  Suggestions for improvements are welcome.
msg148846 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-12-04 09:20
Hello Jon, and thanks for the patch. I have a couple of comments:

- readinto() shouldn't return None but 0 when there is nothing to read (this corresponds to read() returning b"")

- I see _read_chunked() is only ever called with amt=None, so perhaps it can be simplified?

Also, a nitpick: the doc entry needs a "versionadded" tag.
msg148852 - (view) Author: Jon Kuhn (Jon.Kuhn) * Date: 2011-12-04 16:54
Thanks for the comments.  Attached is an updated patch.

In the RawIOBase docs it says "If the object is in non-blocking mode and no bytes are available, None is returned."  So I wasn't sure if that meant any time no bytes were available or just when no bytes are available and EOF has not been reached.  -- I updated it to return 0 instead of None.

I simplified _read_chunked() and renamed it to _readall_chunked() since that is all it does.  

I added the versionadded tag specifying that it was added in 3.3 since the patch is for the default branch.
msg148939 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-12-06 21:39
New changeset 806cfe39f729 by Antoine Pitrou in branch 'default':
Issue #13464: Add a readinto() method to http.client.HTTPResponse.
msg148940 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-12-06 21:41
Ok, thank you. I've now committed the patch in the default branch. Congratulations!

(since the documentation doesn't claim that HTTPResponse implements RawIOBase, I tend to consider this a feature request rather than a bugfix, hence no 3.2 commit)
msg150627 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-04 17:58
New changeset 4b21f651eeee by Antoine Pitrou in branch 'default':
Issue #13713: fix a regression in HTTP chunked reading after 806cfe39f729
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57673
2020-10-23 19:09:49fbidusetnosy: + fbidu

pull_requests: + pull_request21847
2012-01-04 17:58:37python-devsetmessages: + msg150627
2011-12-06 21:41:39pitrousetstatus: open -> closed
versions: - Python 3.2
type: behavior -> enhancement
messages: + msg148940

resolution: fixed
stage: patch review -> resolved
2011-12-06 21:39:54python-devsetnosy: + python-dev
messages: + msg148939
2011-12-04 16:54:48Jon.Kuhnsetfiles: + issue13464_r1.patch

messages: + msg148852
2011-12-04 09:20:47pitrousetmessages: + msg148846
stage: patch review
2011-12-04 04:36:11Jon.Kuhnsetfiles: + issue13464.patch

nosy: + Jon.Kuhn
messages: + msg148837

keywords: + patch
2011-11-23 18:13:58r.david.murraycreate