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.

Author nikratio
Recipients benjamin.peterson, hynek, nikratio, pitrou, r.david.murray, serhiy.storchaka, stutzbach
Date 2013-07-24.18:24:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <51F01C3C.90807@rath.org>
In-reply-to <1374676528.04.0.31945479131.issue18524@psf.upfronthosting.co.za>
Content
On 07/24/2013 07:35 AM, Antoine Pitrou wrote:
> 
> Antoine Pitrou added the comment:
> 
>> This means that read1() will only return up to n bytes if n is smaller
>> than the buffer size, otherwise it will return at most <buffer-size>
>> bytes.
> 
> Did you actually observe such behaviour? If so, this is a bug.

Yes, that's what I see:

$ python3 bug.py
Read 20 bytes using read()
Read 10 bytes using read1()

$ cat bug.py
#!/usr/bin/env python3

import io

raw = io.BytesIO(bytes(200))
buffered = io.BufferedReader(raw, 10)

data = buffered.read(20)
print('Read %d bytes using read()' % len(data))

data = buffered.read1(20)
print('Read %d bytes using read1()' % len(data))

There should be no problem reading 20 bytes with a single call to
BytesIO.read(), yet the buffered reader returns only 10 bytes.
History
Date User Action Args
2013-07-24 18:24:52nikratiosetrecipients: + nikratio, pitrou, benjamin.peterson, stutzbach, r.david.murray, hynek, serhiy.storchaka
2013-07-24 18:24:52nikratiolinkissue18524 messages
2013-07-24 18:24:52nikratiocreate