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(bindings/python): Make sure read until EOF #4995

Merged
merged 6 commits into from
Aug 15, 2024
Merged

Conversation

Bicheka
Copy link
Contributor

@Bicheka Bicheka commented Aug 10, 2024

Which issue does this PR close?

Closes #4990

Rationale for this change

There wasn't any warantee that the entire file would fit inside the size variable therfore read in chunks until EOF in the case that the file size is large

@Xuanwo Xuanwo changed the title Fix #4990 guarantees read until EOF fix(binings/python): Make sure read until EOF Aug 11, 2024
bindings/python/tests/test_read.py Outdated Show resolved Hide resolved
bindings/python/tests/test_read.py Show resolved Hide resolved
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thank you for your effort. However, I believe this fix is incorrect.

The root cause lies in:

read_content = reader.read(size + 1)

where the length of read_content does not equal size + 1.

Therefore, we should not directly compare read_content with content. Instead, we need to gather all read_content and then perform the assertion.

This commit addresses the issue raised in the pull request apache#4989, where the `read()` operation did not always return the expected content length.

Changes include:
- Implementing a loop to gather all content chunks until EOF.
- Performing the assertion after the entire content has been read.

This ensures that the test passes stably by correctly handling cases where `read()` may not return the full content in one go.
@Bicheka Bicheka requested a review from Xuanwo August 11, 2024 17:04
@Bicheka Bicheka requested a review from Xuanwo August 13, 2024 22:04
Copy link
Contributor Author

@Bicheka Bicheka left a comment

Choose a reason for hiding this comment

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

deleted the code requested in pr code review

bindings/python/tests/test_read.py Outdated Show resolved Hide resolved
@Bicheka Bicheka requested a review from Xuanwo August 14, 2024 22:46
@Xuanwo Xuanwo changed the title fix(binings/python): Make sure read until EOF fix(bindings/python): Make sure read until EOF Aug 15, 2024
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution first.

However, I'm not happy working on this PR with you. I feel like you haven't put in as much effort as I have. Sometimes, your changes make me feel like you're committing them without much thought.

Apologies in advance if I have made any wrong assumptions. Please let me know if there are areas where we can improve.

@Xuanwo Xuanwo merged commit ea11730 into apache:main Aug 15, 2024
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: python's test doesn't use reader correctly
2 participants