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

Fix read bytes count #463

Closed
wants to merge 3 commits into from
Closed

Fix read bytes count #463

wants to merge 3 commits into from

Conversation

z2v
Copy link
Contributor

@z2v z2v commented Aug 11, 2015

read attempts to read up to chunk_size bytes. So real chunk length can be less than chunk_size.

`read` attempts to read *up to* `chunk_size` bytes. So real chunk length
can be less than `chunk_size`.
@@ -67,6 +68,8 @@ def __init__(self, content):

@asyncio.coroutine
def read(self, size=None):
if size is not None:
size = random.randint(size // 2, size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike the test.
Let's assume we will break the code again.
Looking on random test failures I'll have no clue what's broken.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Better see separate test function that reproduces that behaviour.

@asvetlov
Copy link
Member

@kxepal would you see the PR in 0.17.2 bugfix release?

@kxepal
Copy link
Member

kxepal commented Aug 11, 2015

Would be nice to have.

@z2v
Copy link
Contributor Author

z2v commented Aug 11, 2015

@asvetlov, @kxepal I've added test function for the case.

if not chunk:
break
chunks.append(chunk)
result = b''.join(chunks)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use bytearray instead of list with further join.

@z2v
Copy link
Contributor Author

z2v commented Aug 11, 2015

Not sure about Travis failure reason. Locally test passes with Python 3.4.3. I'll rewrite stream object without inheritance later.

@asvetlov
Copy link
Member

Fixed in 0.17 branch.
@z2v thanks!

@asvetlov asvetlov closed this Aug 11, 2015
if size is not None and self._first:
self._first = False
size = size // 2
return super().read(size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be return (yield from super().read(size)).
I've fixed it already.

@z2v z2v deleted the bug/wrong-read-bytes-count branch August 12, 2015 09:12
@lock
Copy link

lock bot commented Oct 30, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants